1

I want to validate a field,

I am using the CI form validation library,

Just for in case, i want to validate a name field,

So i want to set the rules like this..

$this->form_validation->set_rules('title', 'Title', 'required|min_length[2]|alpha');

but the problem is that, when i am entering the value as "Saswat Routroy",

Then also its stating me that "Title field must contain alphabets."

How can i set rules so that anything other than alphabets and the space will be restricted.

Note: I dont want to use any callback function
Saswat
  • 12,320
  • 16
  • 77
  • 156
  • 1
    why not callback, not comfy? Please see this for more information http://stackoverflow.com/questions/13982529/form-validation-rules-for-regex-match – Kyslik Jul 21 '14 at 07:43
  • you are getting error because `space is not a valid alpha` you can use regex as suggested by Adeel. – Karan Thakkar Jul 21 '14 at 19:06

1 Answers1

0

I came up with this solution for you.

$this->form_validation->set_rules('title', 'Title', 'required|min_length[2]|
                                   regex_match[/^[a-zA-Z ]*$/]');
Adeel Raza
  • 628
  • 5
  • 17