EasyUI Forum
November 04, 2025, 09:16:49 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: validatebox: how to prevent check on each keystroke  (Read 11947 times)
Ellipsis
Full Member
***
Posts: 113


View Profile WWW
« 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.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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
});
Logged
Ellipsis
Full Member
***
Posts: 113


View Profile WWW
« Reply #2 on: October 25, 2012, 08:57:55 AM »

Thank you!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!