Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript jQuery Validation Re: jQuery Validation

#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;
}
});
});