The JQuery Validate is a feature-rich, regular validation plug-in that provides the client with powerful authentication capabilities while providing a number of regular options to meet the needs of the application. The plug-in bundles a set of useful authentication methods, including URL verification and email authentication, to provide a more convenient user experience for the client.
It is easier to understand by example.
1 //Defining validation Rules2 rules:{3UserName: {required:true, rangelength:[2,10]},//True indicates a minimum of 2 maximum of 10 restricted characters required4Email: {Required:true, Email:true },5Password: {required:true, Minlength:6},//minimum of 6 characters6 Confirm_password: {7Requiredtrue,8Minlength:5, 9Equalto: "#password"},//Determine if the password is consistentTenAge:{required:true, range:[15,40]}//min 15 max 40 Internal value One}
Define regular rules and prompt for information to improve the user experience.
1 //Custom Prompt Message2 messages:{3 userName: {4Required: "Please enter user name",5Rangelength: "The length of the user name is between 2 and 10" },6 Email: {7Required: "Please enter your email address", 8Email: "Please enter the correct email address" },9 Password: {TenRequired: "Please enter your password", OneMinlength:jQuery.format ("Password cannot be less than {0} characters") }, A Confirm_password: { -Required: "Please enter the confirmation password", -MinLength: "Confirm password cannot be less than 6 characters", theEqualto: "Two times input password inconsistent" }, - age:{ -Required: "Please enter your age", -Range: "Between the ages of 15 and 40 years old" + } -}
Learn about jquery Validate.js No more headaches for regular verification