CodeIgniter Forums

Full Version: Question about forms native rules that are available to use
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, CI have the following native rules that are available to use; alpha, alpha_numeric, alpha_numeric_spaces, alpha_dash and so on... but what if I want to validate a form field for a title or subject with the following common characters; ? ! $ & @

Is there a way to add those to the following native rules; alpha_numeric, alpha_numeric_spaces?

Thank You!
You could extend the form library and then replace the native rules you want to change, but it would be easier to just create your own validation rules, which doesn't require extending the library. See this section in the documentation. I think it's what you need.
http://www.codeigniter.com/userguide3/li...on-methods
(04-01-2015, 11:58 PM)RobertSF Wrote: [ -> ]You could extend the form library and then replace the native rules you want to change, but it would be easier to just create your own validation rules, which doesn't require extending the library. See this section in the documentation. I think it's what you need.
http://www.codeigniter.com/userguide3/li...on-methods

Great! Thank You!
PHP Code:
$this->form_validation->set_rules('q''Q''regex_match[/.*([?!$&@]).*/]'); 
That's an even better reply, gadelat!
OOnly,when you are able to extend library.