EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Ellipsis on October 25, 2012, 01:33:47 AM



Title: validatebox: how to prevent check on each keystroke
Post by: Ellipsis on October 25, 2012, 01:33:47 AM
We defined some custom validates with an external resource (does the given ID exist for example)

The problem is that validatebox fires that request every keystroke, I tried adjusting the custom check to wait until a certain length of the given value but this is not a good solution.
We only want the boxes to be 'validated' on 'blur'(=leaving input) or on submit.


Title: Re: validatebox: how to prevent check on each keystroke
Post by: stworthy on October 25, 2012, 06:41:47 AM
To disable validating when the input box got focus, bind a 'focus' event on this input box and set the inner variable 'validating' to false. The code looks like this:
Code:
$('#box').bind('focus',function(){
  $(this).data('validatebox').validating = false;
}).bind('blur',function(){
  $(this).validatebox('validate');  // call validate method to do the validation when box lose focus
});


Title: Re: validatebox: how to prevent check on each keystroke
Post by: Ellipsis on October 25, 2012, 08:57:55 AM
Thank you!