Is there a way to perform a callback function with jquery's validation plugin that can look for the function in a different controller?
Meaning I have my register controller however I want it to look inside my users model that houses EVERYTHING user related and perform the is_username_available function.
If your validation function is just called is_username_available, you will need to create a decorator for this method, and allow it to be called publicly from your controller.
function validation_username_available($username)
{
if ($this->is_username_available($username))
die("true");
die("false");
}
Then you make an AJAX call to /register/validation_username_available/Bob and read the output, either true or false.
Also, your validation function is_username_available should really be prefixed with an underscore, like _is_username_available. Otherwise it can be accessed publicly through /register/is_username_available/Bob. That is probably something you don't want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With