Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Validating forms with regex in codeigniter

How can I validate a form using regex in codeiginiter. I'd like to check the input against:

^([0-1][0-9]|[2][0-3]):([0-5][0-9])$

I'm assuming the best way is in some sort of callback. I tried a bunch of ideas on the web but I can't seem to get any working.

like image 804
Alex Avatar asked Feb 17 '26 06:02

Alex


1 Answers

Old post but you can add the regex directly in the input validation rule

$this->form_validation->set_rules()

Add to function above: regex_match[your regex]

like image 181
CyberJunkie Avatar answered Feb 19 '26 20:02

CyberJunkie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!