I'm having a problem coding for a form validation. I'll post the code below. Basically i want the form to submit if cboAction is on another selection.
cboAction has three values, [Select], Insert and Search. So if Insert is selected in the combobox then the form should validate using jquery else if Search is selected then the form should get submitted. I tried putting an if statement in there but it didn't work. :(
Btw the form validation works, its just that i can't get the above working. Hope to hear from someone.
Thanks
jQuery.validator.addMethod(
"selectOption",
function(value, element) {
if(element.value == "nothing") {
return false;
} else {
return true;
}
},
"Please select an option."
);
$(document).ready(function() {
$("#authorForm").validate({
rules: {
cboAction: {selectOption:false}
txtName: {required:true},
txtStreet: {required:true}
txtTown: {required:true},
cboState: {selectOption:true},
txtPostcode: {required:true},
txtMobile: {required:true},
txtEmail: {required:true, email:true}
},
messages: {
cboAction: "Please select an action"
txtName: {required: "Author's Name is a required field"},
txtStreet: {required: "Street is a required field"}
txtTown: "Town is a required field",
cboState: "Please select a state",
txtPostcode: "Postcode is a required field",
txtMobile:
{
required: "Mobile is a required field",
email: "Please enter a valid email adress"
}
}
});
});