The onChange Event

This Event Handler works much the same way as the onBlur Event Handler. In the old days, the effects of an onChange event would be triggered by revisiting the input box, even if the user did not change anything. Authors had preferred to use the onFocus command. However, the good news is that today's browsers handle the onChange command perfectly -- the alert is triggered only if the input text box has been changed in any way. The main function of this command is to work as a check mechanism, making sure the user fills in what you are asking for:

HTML file: Displayed by browser:
<body>

<FORM>
<H4>This is an onFocus input text box:</H4>
<INPUT TYPE="text" SIZE="30"
onFocus="window.status='Write your name in the box';">
<BR /><BR />
<HR />
<H4>This is an onChange input text box:</H4>
<INPUT TYPE="text" SIZE="40"
onChange="alert('This text box has been changed');">
</FORM>

</body>

This is an onFocus input text box:




This is an onChange input text box:

The problem with the onFocus Event Handler, is that the text stays in the status bar, even if you focus on the other input text box. That is, when operating from the hard drive. Online, there is nothing in the status bar at all -- the onFocus just doesn't work online. I tried putting both Event Handlers as one, separated by a comma, but nothing worked at all.

BackTable of ContentsNext