Cancel the blur handler based on the item that was clicked

Greetings, wonderful people!

My problem this time is checking if mouseClick happened with a blur expression.

I have a global solution in which every input field is checked for BLUR. Inside this event, I need to check whether an element (for example, helpBubble) was clicked, if it is, I do not want the check to be performed, however, if this particular element was not clicked, the check still needs to happen.

Any help would be greatly appreciated!

+3
source share
1 answer

blur click . , onblur , , -. :

var validationTimer;
$('#myform input').blur(function(){
  var blurred = $(this);
  validationTimer = setTimeout(function(){
    validationTimer = null;
    // Perform Validation on 'blurred'.
  },100);
});

$('.helpbubble').click(function(){
  if (validationTimer){
    clearTimeout(validationTimer);
    validationTimer = null;
  }
});

100 , ( ), .

. : http://jsfiddle.net/9SzDP/

+6

Source: https://habr.com/ru/post/1781854/


All Articles