Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#11632 closed enhancement (worksforme)

ValidationTextBox: setting a custom error-message

Reported by: Chris2 Owned by:
Priority: high Milestone: tbd
Component: Dijit - Form Version: 1.5
Keywords: ValidationTextBox, custom message Cc:
Blocked By: Blocking:

Description

As stated on following site: http://docs.dojocampus.org/dijit/form/ValidationTextBox-tricks

it is possible to override validator to do some custom validations maybe on server-side (async). But there is not stated how to apply a custom error message to the ValidationTextBox? when that server-function returns. The method "displayMessage" looks like i am looking for but it does not set the error state. An new function which accomplishes that would be nice. Something like:

function setError(msg){
	this.state = "Error";
	this._setStateClass();
	dijit.setWaiState(this.focusNode, "invalid", "true");
	this.displayMessage(msg);
}

But i got no idea how to prevent that "validate" removes the error-state on refocus. Overriding validate seems not to be the best idea.

Background: Currently i am not overriding "validator" because i just want to validate after lost focus and keep the regexp-validation. So i am using onBlur to send a request to the server.

Change History (2)

comment:1 Changed 9 years ago by bill

Resolution: worksforme
Status: newclosed

Well you would need to override isValid() to return false (after you got your validation response from the server). I think that will do it for you. Plus either overriding getErrorMessage() or with the newest code I guess you could do a set("message", ...).

comment:2 Changed 8 years ago by bill

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