I have 4 fields where the user should enter values in at least one of them. So I am trying to validate that each of these 4 fields will be required just when all of them are empty otherwise it won't be required.
The rule seems to be working for the one field I picked to try first, but the required error remains even after I provide a value.
This is my code:
$("#ProspectDtlFrm").validate({
rules: {
prsptEmail: {
required: function(element) {
return (
$("#prsptHomePhone").val() == '' &&
$("#prsptBusinessPhone").val() == '' &&
$("#prsptMobilePhone").val() ==''
)
}
}
},
messages: {
prsptEmail: "Please enter your first name"
}
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…