CodeIgniter Forums
Question about forms native rules that are available to use - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Question about forms native rules that are available to use (/showthread.php?tid=1690)



Question about forms native rules that are available to use - Mel9pr - 04-01-2015

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!


RE: Question about forms native rules that are available to use - RobertSF - 04-01-2015

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/libraries/form_validation.html#callbacks-your-own-validation-methods


RE: Question about forms native rules that are available to use - Mel9pr - 04-02-2015

(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/libraries/form_validation.html#callbacks-your-own-validation-methods

Great! Thank You!


RE: Question about forms native rules that are available to use - gadelat - 04-02-2015

PHP Code:
$this->form_validation->set_rules('q''Q''regex_match[/.*([?!$&@]).*/]'); 



RE: Question about forms native rules that are available to use - RobertSF - 04-02-2015

That's an even better reply, gadelat!


RE: Question about forms native rules that are available to use - madaan_tushar - 05-26-2015

OOnly,when you are able to extend library.