CodeIgniter Forums
Custom callback based on 2 fields - 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: Custom callback based on 2 fields (/showthread.php?tid=21604)



Custom callback based on 2 fields - El Forum - 08-15-2009

[eluser]Jhourlad Estrella[/eluser]
Hi, guys. My First time here. Anyway, I hope somebody can help me with my very simple problem with CI.


On my Login controller:

Code:
$this->form_validation->set_rules('f_username', 'Username', 'required|alpha_numeric|xss_clean|min_length[3]|max_length[12]');
$this->form_validation->set_rules('f_password', 'Password', 'required|min_length[8]|max_length[30]');

I am trying to find a way to make my login validation code ad CI compliant as possible so I want to do it using a custom callback function. Is there a place there I can do something to add a custom rule? I've already done this before without hassle but I lost all my codes recently.

Thanks in advanced!


Custom callback based on 2 fields - El Forum - 08-17-2009

[eluser]designfellow[/eluser]
Hi,
create a custom function with your code.
Add that function to validation rules with a prefix of 'callback_'
eg. callback_checkUnique
That's all Smile

Happy coding,
DesignFellow


Custom callback based on 2 fields - El Forum - 08-17-2009

[eluser]Neeraj Kumar[/eluser]
don't forget to add the validation function to your current controller Wink