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

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