I have a <form>
containing two text <input>
s side-by-side. When both of these inputs lose focus, I want to do some stuff (send an Ajax request to server and replace them with something else in the DOM). However if I click or tab from one of the inputs to the other, I don't want to do those things.
Setting an onBlur
event handler on the <form>
element works fine using my setup, but there doesn't seem to be any way to determine if the other form input is my next target. If I examine document.activeElement
in my handler, it points to the <body>
element (in Chrome) at that point. Only afterwards does it change to the other input.
Is there any way to reliably do what I'm asking? Solutions involving jQuery or other libraries are fine.