Search code examples
phpcodeignitervalidation

accept only english character in form validation in codeigniter


I want to accept only English character in a text box form validation in codeigniter. Is there any built form validation method for this or should I use my own validation function for implementing this?


Solution

  • The rule you need is alpha. You could do something like this:

    $this->form_validation->set_rules('text', 'Text','required|alpha');
    

    To ensure that what is entered contains only alphabetical values.

    See the rule reference on the codeigniter documentation.