JQuery Validate Plugin allowing the post of invalid data
I have the following validation rules to my form:
function ValidadeRegistration() {
$('#RegistrationForm').validate({
rules: {
"auth.UserName": {
required : true,
email: true
},
"auth.Password": {
required : true,
minlenght : 5
},
PasswordConfirmation: {
required: true,
minlength: 5,
equalTo: "#password"
}
},
messages: {
"auth.UserName": {
email: 'Por favor digite um e-mail válido.',
required: 'Campo e-mail obrigat&oac开发者_JAVA技巧ute;rio.'
},
"auth.Password": {
required: 'Campo senha obrigatório.',
minlength: 'A sua senha deve conter ao menos 5 caract$eacute;res.'
},
"PasswordConfirmation": {
required: 'Confirmação da senha é obrigatória.',
equalTo : 'A senha não bate.'
}
}
});
}
The error messages display correctly and the plugin blocks the post when I have invalid data in any of the fields, however all it takes to allow the post is presence of data in the "auth.Password" field. If I have anything written in this field (it doesn't even have to be in the length specified) the plugin ignores all other errors and posts.
What am I doing wrong?
minlength
is misspelled:
Current:
"auth.Password": {
required : true,
minlenght : 5
},
Corrected:
"auth.Password": {
required : true,
minlength : 5
},
精彩评论