DelphiFAQ Home Search:

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

 

commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.

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>

Content-type: text/html

Comments:

2017-03-31, 04:33:10   (updated: 2017-03-31, 04:35:25)
serhan from Pakistan  
These JavaScript tricks are always inspiring for me to learn and implement. I got you from the http://www.uk-disse..rvice.com/ and find very helpful for next web project.

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: