Codeigniter form_validation create custom rule/fil

2019-07-11 19:10发布

问题:

Codeigniters form_validation is great, however I need a custom filter that is specifically

alpha space dash and apostrophe/single quote

but.. they don't have that specifically in there existing set, so I am wondering how could I go about creating my own rule/filter and adding it to form_validation.

回答1:

Callbac ks are your friend

You'll just just a custom callback - and put a regex in there that does whatever rule you want.



回答2:

Here is some documentation for CodeIgniter's form validation tool.

http://codeigniter.com/user_guide/libraries/form_validation.html#validationrules