0,var Validator = $ ("#regform"). Validate ({The #regform inside this is the ID in form
1, first to import the JQ into the
2. Each <input> has a name and ID, plus <label for= "Enter_the_password_again" ></label>
The name of the 3,messages, corresponding to the name in the rules.
<!--import JQ--><script src= "Http://static.runoob.com/assets/jquery-validation-1.14.0/lib/jquery.js" > </script><script src= "http://static.runoob.com/assets/jquery-validation-1.14.0/dist/ Jquery.validate.min.js "></script> <!--import Area JS---<script type=" Text/javascript "src=" view/region . js "></script> <script type=" Text/javascript ">function Home () {window.location.href= "View/login.jsp"; } $.validator.setdefaults ({submithandler:function () {add_save (); } }); $ (). Ready (function () {//validate form on commitvar validator = $ ("#regform"). Validate ({errorplacement:function (error, Element) {$ (element ). Closest ("Form"). Find ("Label[for=" + element.attr ("id") + "']"). Append (Error); }, rules: {Password: {R Equired:true, minlength:6, MaxLength:20}, Enter_the_password_again: { Equalto:"#Password"}, phonenumber:{D Igits:true, Required:true, minlength:11, MaxLength:11},}, messages: {Password: {Required:"Password cannot be empty", minlength:"Please input 6--20 words", MaxLength:"Please input 6--20 words"}, Enter_the_password_again: {equalto:"Two times password input inconsistency"}, phonenumber:{digits:"Only enter Numbers", Required:"Please enter your phone", minlength:"Please enter the correct phone number format", MaxLength:"Please enter the correct phone number format" }, } }); $(". Cancel"). Click (function () {validator.resetform (); }); }); </script> for= "Account" ></label> </td> </tr> <tr> <td> password:</td> <td><input type= "text" name= "Password" id= "Password"/> <label for= "Password" ></label> </td> </tr> <tr> <td> Please enter the password again:</td> <td><input type= "text" Name= "Enter_the_password_ Again "id=" Enter_the_password_again "/> <label for= "Enter_the_password_again" ></label> </td> </tr> &L T;tr> <td> Common mobile phone number:</td> <td><input type= "text" Name= "Phonenum ber "id=" PhoneNumber "/> <label for= "PhoneNumber" ></label> </td> </tr> <tr> <td> real name:</td> <td><input type= "text" name= "Realname"/></td& Gt </tr> <tr> <td> ID number:</td> & Lt;td><input type= "text" name= "Idcardnumber"/></td> </tr> <tr> <td> Agent Area:</td> <td> <select id= "province" NA Me= "province" ></select> <select id= "City" Name= "City" ></select> <select id= "area" name= "area" ></select> <script type= "Text/javascript" >Addressinit (' Province ', ' City ', ' area '); </script> </td> </tr> <tr> &L T;td> Company name:</td> <td><input type= "text" name= "Nameofcompany"/></td> </tr> <tr> <td> referrer id:</td> <td> <input type= "text" name= "referees"/></td> </tr> <tr> <td> Agent Avatar:</td> <td><input type= "text" name= "Agencyhead"/></td> </tr> <tr> <td> Corporate photo (handheld ID):</td> <td><input type= "text" name= "Photoagencyasalegalperson"/></td> </t R>
Authentication at the time of registration