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 select between several different "groups", and each group has its own distinct set of email addresses (thus the same email can exist once in each group).
The group selection is a dropdown on the form, and the email address is an input field with remote validation. I have a couple issues. First, I have set up my remote rule like this:
remote: {
url: 'remote_script.php',
data: { group_id: $('select.group_id').val() }
}
However, this seems to statically set the group_id parameter to whatever the first value in the select is. Meaning, if I change the select, then trigger the remote validation again, the group_id parameter does not change
First, how can I make this parameter dynamic, depending on the value of a select in the form?
Secondly, how do I manually trigger the remote validation on the email address field? When the group_id select is changed, I want to re-trigger the remote validation on the email address field (without changing the value of the field). I tried using
$(selector).validate().element('.email_addr')
But this appears to only trigger the standard validation (required, email), and not the remote call.