Home › Forums › JavaScript › jQuery Validation › Re: jQuery Validation
February 8, 2013 at 12:12 pm
#123798
Member
How does something like this look?
$(“form”).on(“submit”, function(e){
$(“input”).each(function(){
var $this = $(this);
if($($this).val() == “”){
var name = $($this).attr(“name”);
var li= $(“
“, {
text: “There was an error with ” + name,
class: “errorText”,
});
$($this).addClass(“errorInput”);
$(“.errorMessage”).append(li);
e.preventDefault();
}else if($($this).val() != “”){
$($this).removeClass(“errorInput”);
}else{
return true;
}
});
});