[jQuery] (validate) conditional statements in .validate
Hi,
I would like to make fields required based on a country selection in a
drop down. I tried a few variations of the following but can't get it
to work. Is there another way of going about this?
$("#country").change(function(){
var ctry= $("#country").val();
if ( country == "United States"){
$("#checkoutGuestDynForm").validate({
rules: {
state: "required",
zipCode: {
required:true,
maxlength: 10,
minlength: 5
},
phone:"required" {
});
}
else if (country == "Canada"){
$("#checkoutGuestDynForm").validate({
rules: {
province: "required",
postalCode: "required",
phone:"required"}
});
}
else (country == "Intl"){
$("#checkoutGuestDynForm").validate({
rules: {
stateIntl: "required",
zipCodeIntl: "required",
phoneIntl:"required"
}
});
}
});