javascript - jquery validate plugin, display one error at a time with css -
i want know how can display error messages on bottom of screen using jquery,validator plugin
also it's suppose display 1 error @ time.
for eg:-
name:- first error of name
email:- once name validated email's error displayed
website:-finally website's error.
and how highlight textbox of field 1 one same style:
< input type="text" name="name" >
< input type="text" name="email" >
< input type="text" name="website" >
< div id='error' >if name blank display name blank, if not check email , after website< /div >
i don't know how whole coding going like.
please provide coding snippet.
thanks in advance
dave
try this:
$("#myform").validate({ // validation rules , messages go here showerrors: function(errormap, errorlist) { $("#myform").find("input").each(function() { $(this).removeclass("error"); }); $("#myerrorcontainer").html(""); if(errorlist.length) { $("#myerrorcontainer").html(errorlist[0]['message']); $(errorlist[0]['element']).addclass("error"); } } }); this place 1 error @ time inside element has myerrorcontainer id, , @ same time highlight element causing error adding .error class it.
hope helps !
Comments
Post a Comment