jquery add method and implementation
Ok so from my previous post I got a lot of good feedback. I am starting this one so that I can start a new question and add the full code I have. i know something is messing up, but here is my method and implementation.
jquery.validator.addMethod("passwordRules", function(input) {
var reg = /^{^%\s]{6,}$/;
var reg2 = /[a-zA-Z]/;
var reg3 = /[0-9]/;
return reg.test(input) && reg2.test(input) && reg3.test(input);
});
that is my add method. here is how I am trying to apply it to the new password field. My question here is do i use required? I am lost.
$("开发者_如何转开发<%= NewPass1.GetName() %>").validate({
rules:{
required: { passwordRules: true }
}, messages: {
"<%= NewPass1.GetName() %>": {
required: WrapError("Invalid", "The password contains invalid....")}
}
});
I just need to reassure that the password box only allows min of 6 chars, no spaces or %, at least one number and at least one letter.
If you define a new method, you simply have to use the method name as a key in the rules set like this:
$("<%= NewPass1.GetName() %>").validate({
rules:{
passwordRules: true
}
});
d.
精彩评论