CodeIgniter Forums
Question About Validation Class - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Question About Validation Class (/showthread.php?tid=11069)



Question About Validation Class - El Forum - 08-25-2008

[eluser]gedev2006[/eluser]
Hi

I know you can set rules to the validation class as such:

$rules['item_name'] = "trim|alpha"

and so forth

WHat i need to have is a field that allows alpha_dash, and allow the bracket symbols ().But the only way i can get the brackets in is alpha or alpha_numeric but then the alpha_dash doesnt work correctly

any ideas?

cheers

g


Question About Validation Class - El Forum - 08-25-2008

[eluser]Colin Williams[/eluser]
Do a custom callback method.


Question About Validation Class - El Forum - 08-25-2008

[eluser]gedev2006[/eluser]
Yeh i thought of that, but then would you check the rules the exact same way ??

Also, in the custom error fields say:

$fields['zip'] = "Zip Code";

Codeigniter adds its own message to the end so the output of the error would read something like

Zip Code field may only contain alpha-numeric characters.

How do i prevent code igniter adding "field may only contain alpha-numeric characters." to the end so its a completely custom error message. $this->validation->set_message ( "zip", "bla bla" ) does nothing!


Question About Validation Class - El Forum - 08-25-2008

[eluser]Colin Williams[/eluser]
The set_message method needs the name of the callback method as the first param, not the name of the field.