I'm writing a registration form script with jquery validation and need to pass a variable to the submit button so that if there is an error the form will not submit. Here is my code for one row in the form:
function check_email(){
var email = $('#email').val();
var filter = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
if(!filter.test(email)){
$('.emailStatus').removeClass("success").addClass("error");
}
else {
$('.emailStatus').removeClass("error").addClass("success");
[SOMETHING TO INDICATE NO ERROR OCCURS]
}
}
Then when I submit the form I need it to be able to find that NO Errors occur based on the [SOMETHING TO INDICATE NO ERRORS] line and perform a function. I'm sorry if this isn't clear but I don't have much experience with Javascript but would love if if I could get this form to work. Could it be done with a variable in the if statement?
Thank you