问题
I am using dojo as the client framework. I have a ValidationTextBox
call txtName
as below screen:

In txtName
, required
is set:
required="true"
If I lose focus and leave txtName
empty (tab, or click to another textbox), the validation execute immediately by highlighting by red.
My question: Is there anyway that we turn off this, and just only do validation when I click on Save
button. I tried set:
intermediateChanges="false"
but no luck. The same situation with StartDate
and EndDate
回答1:
There isn't a setting that you can just set. But you can monkey patch the ValidationTextBox
to get what you need.
ValidationTextBox.prototype._setValueAttr = function() {
//this.inherited(arguments);
//this.validate(this.focused); Do not validate
TextBox.prototype._setValueAttr.apply(this, arguments);
};
ValidationTextBox.prototype._refreshState = function(){
TextBox.prototype._refreshState.apply(this, arguments);
};
The full working example: http://jsfiddle.net/cswing/Y7Eqn/
来源:https://stackoverflow.com/questions/14979144/turn-off-instant-validation-when-losing-focus