jQuery validate select onChange
Hi,
I'm trying to validate the state name of a country in a form
when enter a state name I have it validated ( in "xhr/xhr_validate_key.php" ).
Would need when I change the country (in the country_id.onchange)
revalidate the state name
The state name is marked as invalid and not sumit the form
if I change the country
Sorry for my bad English, I'm from Argentina
<tr>
<td>State Name</td>
<td>
<input type="text" name="name" id="name" value="<?=$name?>" maxlength="50" size="52" />
</td>
</tr>
<tr>
<td>Country</td>
<td>
<select style="width:100px;" id="country_id" name="country_id" >
<?=$countryOptions?>
</select>
</td>
</tr>
$(document).ready(function(){
$("#states").validate({
rules: {
name: {
required:true,
remote: {
url: "xhr/xhr_validate_key.php",
type: "get",
data: {
u: "<?=$state_id?>",
i: "state_id",
t: "states",
f: "name",
v: function() {
return $("#name").val();
},
a: function(){
return 'country_id="' + $("#country_id").val() +'"';
}
}
}
},
}
});