Alex Rivera | Logout

How to force to lose focus of all fields in a form in jQuery

Asked 2013-05-27T19:15:06.780
56

When a input field changes (onchange) I trigger a function to set a variable. The only problem is that the field first has to lose focus before the variable is set and I can check if the field(s) is changed, this is what I want to do when the user clicks on a tab so I can check if the user is forgotten to submit his form in the previous tab. Ho to force lose focus of all possible fields, so first the onchange event can take place?

Edit
Report

1 Answer

4

You can trigger a .blur() event

$('SomeElement').blur(function () {
   // do whatever
});

$('SomeElement').blur();
answered 2013-05-27T19:16:12.430

Your Answer