Turn off instant validation when losing focus

自闭症网瘾萝莉.ら 提交于 2019-12-10 21:34:58

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!