I am creating a contact form and I need help with the jQuery validator.
function contactform() { $("form #submit").on("click", function() { $("form input").removeClass("error"); validator();
validator() checks to see if any input is empty, and if it adds an error class to it:
function validator() { $("form input").each(function() { var value = $(this).val(); if (value.length <= 0) { $(this).addClass("error"); return false; } }); });
Now, for the third action in contactform() , I want to say that if validator() = true (i.e. there are no inputs that are empty), go to the next code.
I cannot return validator() value. Does anyone know a better way to do this?
izolate
source share