Html:
<form id= "Reg" action= "123.html" >
<p class= "Myerror" ></p>
<p> account: <input type= "text" name= "user" id= "user"/></p>
<p> Password: <input type= "text" name= "pass" id= "pass"/></p>
<p> Zip: <input type= "text" name= "code" id= "code"/></p>
<p><input type= "Submit" value= "Submission"/></p>
</form>
CSS: (partial)
. valid {
Background:url (.. /img/reg_succ.png) no-repeat right;//picture for the successful
}
Js:
$ (function () {
Custom validation Rules
$.validator.addmethod (
"Code",
function (value,element) {
var tel=/^[0-9]{6}$/;
return this.optional (Element) | | (Tel.test (value));
},
"Please enter the correct ZIP code!" "
);
Plug-in verification
$ (' #reg '). Validate ({
Submithandler:function (form) {
Alert (' Verify successful, ready to submit! ‘);
},
rules:{
user:{
Required:true,
Minlength:6
},
pass:{
Required:true,
Minlength:6
},
code:{
Required:true,
Code:true
}
},
messages:{
user:{
Required: "User name is not empty!" ",
MinLength: "Minimum length of not less than 6 bit"
},
pass:{
Required: "The password is not empty!" ",
MinLength: "Minimum length of not less than 6 bit"
},
code:{
Required: "Mailbox is not empty"
}
}
})
});
:
Validate form Validation for jquery