Handle document on changed event in JavaScript

Description

The following code shows how to handle document on changed event.

Example


<html>
<body>
<script language="JavaScript">
function handleChange(evnt){<!--from  www .j ava 2 s .  c o m-->
alert("The text in TextBox1 has been changed");
return true;
}
document.onchange = handleChange;
</script>
This triggers an alert box to open
up informing you that the text in box 1 has been changed.
<br><br>
<form name="form1">
TextBox1:
<input type="text" size="20" name="text1" onChange=''>
<br><br>
TextBox2:
<input type="text" size="20" name="text2">
</form>
</body>
</html>

Click to view the demo

The code above generates the following result.

Handle document on changed event in JavaScript
Home »
  Javascript Tutorial »
    Event »
      Browser Event
Javascript Tutorial Browser Event
Access window event in JavaScript
Add event handler for body onload event in ...
Add event handler for window on load event ...
Add onload event handler by using attribute...
Cancel event with preventDefault in JavaScr...
Filter click event to capture in JavaScript
Filter event to catch in JavaScript
Handle Error event on body in JavaScript
Handle browser window resize event in JavaS...
Handle document on changed event in JavaScr...
Handler document on abort event in JavaScri...