失去焦点时关闭即时验证 [英] Turn off instant validation when losing focus

查看:147
本文介绍了失去焦点时关闭即时验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用dojo作为客户端框架。我有一个 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆