Home › Forums › JavaScript › jQuery Validation › Re: jQuery Validation
February 7, 2013 at 5:51 pm
#123735
jcoder
Member
Hi John,
Thanks for the help, it worked!
I have modified your code a little below and I’m just curious why you don’t think this is well written code? I’m new to jQuery but would love to learn best practices.
$(“form”).on(“submit”, function(e){
$(“input”).each(function(){
var name = $(this).attr(“name”);
if($(this).val() == “”){
console.log(“There was an error” + ” ” + name);
e.preventDefault();
}else{
return true;
}
});
});