Turn off instant validation when losing focus

2019-07-01 14:11发布

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

enter image description here

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条回答
趁早两清
2楼-- · 2019-07-01 14:22

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/

查看更多
登录 后发表回答