I\'m trying to remote validate a field by looking at two different fields. The issue is, in all the examples I see on how to do remote validate sending additional data, they\'re
You could assign a unique formId
to each of the forms, and whenever the form is submitted, you could submit the formId
alongwith the other info from the form in order to identify which form is being submitted?
For example, in the html code of your form, you could do something like this:
Form # 1: (with form id as 1)
<form id="form_1">
Name: <input type='text' id='name_1'> <br>
Address: <input type='text' id='address_1'> <br>
<input type='button' value='Submit' onclick='validate(1);'>
</form>
Form # 2: (with form id as 2)
<form id="form_2">
Name: <input type='text' id='name_2'> <br>
Address: <input type='text' id='address_2'> <br>
<input type='button' value='Submit' onclick='validate(2);'>
</form>
In the javascript, something like this:
function validate(formId)
{
var data = {};
//Example data that is to be submitted for validation:
data.name = $("#name_" + formId).val();
data.address = $("#address_" + formId).val();
//.. and so on
data.formId = formId;
$.post('http://example.com/confirm.php', data, function(result)
{
//process the return of the remote validation here,
//found in the variable: result
}
);
}