DelphiFAQ Home Search:
General :: Web publishing :: JavaScript :: Events
Questions, answers and code examples dealing with javascript event handlers.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

Detect form input changes when user clicks on another frame or browser window

Question:

When the user clicks on another browser window or frame, a form fields' onChange event handler is not triggered. Is there a way to detect input changes in this situation?

Answer:

The onblur event fires on the original object before the onfocus or onclick event fires on the object that is receiving focus. Where applicable, the onblur event fires after the onchange event. So in your situation you may use the onblur event handler to check the current value of the form with a value captured using the onfocus event handler for the form field as shown below.

<form>
 <input type="text" 
  onfocus="window.temp=this.value" 
  onblur="if (window.temp != this.value) alert('Changed')"  
  onchange="alert('Changed')">
 </form>

Generated 8:02:19 on Feb 20, 2017