Side navigation
#2473 closed bug (fixed)
Opened March 07, 2008 04:42PM UTC
Closed March 20, 2008 11:57AM UTC
[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 (2)
Changed March 07, 2008 05:17PM UTC by comment:1
Changed March 20, 2008 11:57AM UTC by comment:2
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.
The same problem might occur for result == "pending" (~ line 418)