I have a form in which I am using remote validation to check if an email address already exists in the database. However, the catch is that on this form, the user can selec
Found the solution to the second part of my question:
$(".email_addr").removeData("previousValue");
will remove the cache of the remote request, and allow the remote request to be triggered again, using .element().
Thus my code is as follows:
$("select.group_id").change(function() {
$(".email_addr").removeData("previousValue"); //clear cache when changing group
$("#customer_form").data('validator').element('.email_addr'); //retrigger remote call
//my validator is stored in .data() on the form
});
Solution was found here: solution
The first part of my question was answered originally by @Jeffery To
All that needs to be done is to change the value of the parameter to a function, rather than just a value. Jeffery's example is copied below for future googlers:
remote: {
url: 'remote_script.php',
data: {
group_id: function () {
return $('select.group_id').val();
}
}
}
From the second example for remote it looks like functions (evaluated during validation) can be used for data, so
remote: {
url: 'remote_script.php',
data: {
group_id: function () {
return $('select.group_id').val();
}
}
}
should work.
For your second question, did you try passing the validation rules to validate()
?