Opened 15 years ago
Closed 15 years ago
#2473 closed bug (fixed)
[validate]
Reported by: | gregers | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | plugin | Version: | 1.2.1 |
Keywords: | validate required optional | Cc: | |
Blocked by: | Blocking: |
Description
I'm having the same problem as Steven N. Severinghaus described on the plugin homepage (http://bassistance.de/jquery-plugins/jquery-plugin-validation/) 25. Mai 2007 16:10.
When having multiple rules for an element, it will not test the rules after required if required=false. Not specifying required, or moving required to be the last rule will prevent the bug.
rules: {
username: {
required: false, minlength: 3 /* ignored!!! */
}, nickname: {
minlength: 3 /* OK */ required:false,
}, firstname: {
minlength: 3 /* OK */
}
}
I have a patch, but it should be reviewed, as I don't understand everything in the validate core.
Attachments (1)
Change History (3)
Changed 15 years ago by
Attachment: | validate.required.patch added |
---|
comment:2 Changed 15 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
The problem here is that required: false is handled exactly as required: true, which is obviously not what you want. If you want to make a field optional, you have to avoid specifying required at all.
Well, you had to. I've added a check that skips rules with a boolean-false as the parameter, see [5097].
This makes {required: false, minlength: 3} and {minlength: 3} equivalent. To be released as 1.2.2 pretty soon.
Patch suggestion (diff -u)