失去焦点时关闭即时验证 [英] Turn off instant validation when losing focus
问题描述
ValidationTextBox
调用 txtName
如下屏幕:
在 txtName
,需要
设置:
required =true
如果我失去焦点,离开 txtName
空(选项卡,或单击另一个文本框),验证通过突出显示红色立即执行。我的问题:有没有,我们关闭这个,只有当我点击保存
只做验证。按钮。我尝试设置:
intermediateChanges =false
但没有运气。同样的情况与 StartDate
和 EndDate
没有可以设置的设置。但是您可以通过猴子修补 ValidationTextBox
来获取所需的东西。
ValidationTextBox.prototype._setValueAttr = function(){
//this.inherited(arguments);
//this.validate(this.focused);不要验证
TextBox.prototype._setValueAttr.apply(this,arguments);
};
ValidationTextBox.prototype._refreshState = function(){
TextBox.prototype._refreshState.apply(this,arguments);
};
完整的工作示例: http://jsfiddle.net/cswing/Y7Eqn/
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
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/
这篇关于失去焦点时关闭即时验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!