Opened 14 years ago

Closed 14 years ago

Last modified 11 years ago

#6568 closed defect (fixed)

ValidationTextBox has state problem in validate() method

Reported by: [email protected] Owned by: Douglas Hays
Priority: high Milestone: 1.2
Component: Dijit - Form Version: 1.1.0
Keywords: ValidationTextBox validate Cc:
Blocked By: Blocking:

Description (last modified by bill)

Hi, I found a ValidationTextBox widget is not corrected in the following situation:

1) When inputing empty value in it, or set in a program way, though the field is not require, the validation method still consider it as invalid input.

2) When the field is set to Diabled(I wonder if readOnly should handle as the same) status, the field should be clear and reset its validation status. But now it'll continue showing the invalid message.

I think we can handle this problem by change the line of assigning value to state property in ValidationTextBox? 108:

this.state = (isValid || (!this._hasBeenBlurred && isEmpty)) ? "" : "Error";

I recommand it to be change as following:

this.state = (isValid || (!this._hasBeenBlurred && isEmpty && this.required) || this.disabled (|| this.readOnly?)) ? "" : "Error";

This means the validate method would only be activated for the required fields which are activated.

Change History (6)

comment:1 Changed 14 years ago by guest

Sorry, the code still have error, it should be like this:

    this.state = !this.required ? "" : "Error";
    this.state = (isValid) ? "" : "Error";
if(this.disabled )
    this.state = "";

The state map of a Validation widget as below:

 Required   | isValid   | isEmpty  | Disabled     | Focused    |   State
   True     | True/False|   True   |   False      | True/False |   Error
   False    | True      |   True   |   False      | True/False |   Normal
True/False  | True      |   False  |   False      | True/False |   Normal
True/False  | False     |   False  |   False      | True/False |   Error
True/False  | True/False|True/False|   True       | True/False |   Normal

comment:2 Changed 14 years ago by bill

Cc: [email protected] removed
Description: modified (diff)
Owner: set to Douglas Hays
Reporter: changed from guest to [email protected]

comment:3 Changed 14 years ago by Douglas Hays

Status: newassigned


isValid || (!this._hasBeenBlurred && isEmpty)


isValid || (!this._hasBeenBlurred && isEmpty && this.required)

is redundant since isValid would be true for isEmpty and !required.
Adding a check for readOnly is wrong since readOnly fields are submitted with forms and need to be validated.
Disabled fields should not be validated and thus this ticket can be used to fix that.

comment:4 Changed 14 years ago by Douglas Hays

Resolution: fixed
Status: assignedclosed

(In [14286]) Fixes #6568. Remove error state for disabled fields. Added a testcase to test_validationState.html to disable/enable a field to see the effect on form submission.

comment:5 Changed 14 years ago by Douglas Hays

(In [14316]) References #6568. Check for valueNode in case postCreate hasn't run yet.

comment:6 Changed 11 years ago by bill

Component: DijitDijit - Form
Note: See TracTickets for help on using tickets.