Bug Tracker

Opened 12 years ago

Closed 12 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)

validate.required.patch (1.2 KB) - added by gregers 12 years ago.
Patch suggestion (diff -u)

Download all attachments as: .zip

Change History (3)

Changed 12 years ago by gregers

Attachment: validate.required.patch added

Patch suggestion (diff -u)

comment:1 Changed 12 years ago by gregers

The same problem might occur for result == "pending" (~ line 418)

comment:2 Changed 12 years ago by joern

Resolution: fixed
Status: newclosed

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.

Note: See TracTickets for help on using tickets.