Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter form validation. Alpha and spaces

Tags:

codeigniter

When using Codeigniter form validation, does alpha allow spaces? Ex. "Bob Smith"

like image 638
khejduk Avatar asked Feb 06 '12 17:02

khejduk


People also ask

How to validate form in CodeIgniter?

Setting Validation Rules CodeIgniter lets you set as many validation rules as you need for a given field, cascading them in order, and it even lets you prep and pre-process the field data at the same time. To set validation rules you will use the set_rules() method: $this->form_validation->set_rules();

Which rules returns false if the form element is empty?

Validation Rule Reference. Given below are the most commonly used list of native rules available to use. Returns FALSE if the form element is empty. Returns FALSE if the form element does not match the one in the parameter.

How to set error message in CodeIgniter?

PHP_EOL; $data['err'] = $err; $this->load->view('viewname', $data); } else if ($this->form_validation->run() == true ) { #code... } else.. after setting your custom message to $err variable, print it on your view. Save this answer.


1 Answers

One line solution:

 $this->form_validation->set_rules('field', 'Field', 'regex_match[/^([a-z ])+$/i]');

Alpha characters and space.

like image 134
Italo Hernández Avatar answered Oct 16 '22 19:10

Italo Hernández