addMethod in jQuery Validate plugin with required = false
I have a simple script to test if field has alpha caracter
[code]
$.validator.addMethod("hasalpha", function (value) {
return (/[a-z A-Z]/).test(value); // Has at least one letter
}
);
[/code]
and it use this as a rules for my form
[code]
name: {
required: false,
hasalpha: true,
minlength: 5
},
[/code]
The problem I have is that it always fire and error of not having at least 1 alphacaracter when the field is empty, even if required = false
Someone have a clue to solve my problem?
For reference I use this plugin:
http://jqueryvalidation.org/