Hi,
I'm not sure if I'm doing it right, but I'm trying to add some regex validation to the rules.
I assume this is done via the depends mechanism...
but that just errors with
What am I doing wrong?
Is there an easier / better way of validating acceptable input using the jQuery validate plugin?
I cannot see a way mentioned in the documentation.
Thanks,
1DMF
"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Dance Music Downloads
I'm not sure if I'm doing it right, but I'm trying to add some regex validation to the rules.
I assume this is done via the depends mechanism...
Code:
//form validation rules
$("#myform").validate({
rules: {
ID: {
required: true,
[b]depends: function(element) {
return (element.value.match(/[^0-9a-z\-\_]/gi) == '')
}[/b]
}
},
messages: {
ID: {
required: "Please enter a valid UserID",
depends : "Invalid characters found, only use (letters, numbers, underscore or hyphen)"
}
},
submitHandler: function(form) {
form.submit();
}
});
but that just errors with
in the FF error console and the form is still submitted?Error: TypeError: c.validator.methods[e] is undefined
Source File: Line: 29
What am I doing wrong?
Is there an easier / better way of validating acceptable input using the jQuery validate plugin?
I cannot see a way mentioned in the documentation.
Thanks,
1DMF
"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Dance Music Downloads