jValidateallowsforaneasierandcleanerwayofvalidatingformsontheclientside.It’skeyfeaturesarethatitputsvalidationrulesinsemanticHTML(inputswithclassemailarevalidatesasemails,etc),ispassivenotaggressive,iseasytoaccessandtrigger.
Thereareseveralbuiltinvalidationrules;email,url,number,string,ip,date.Aswellasgenerallengthrestrictionswithminimumlength,maxlengthandinarange.It’salsoverysimpletoaddyourownvalidationrules,it’seasiestifyouknowregularexpressionsbutit’snotamust.
Thereareseveralwaystocheckforvalidation:
Withafunction$('input').validate();Withselectors$('input:valid');Withlisteners$('input').listenValidation();Use<inputclass=”email”name=”email”type=”text”/><inputtype=”text”name=”username”rel=”[5,15]”/>//JavaScript$(’form:invalid’).each(function(){ //$(this)isinvalid}$(’forminput’).each(function(){ if($(this).validate()){ //$(this)isvalid }}$(’form*’).listenValidation();
评论