JavaScript » eventhandler » onBlur

Syntax:
onBlur = myJavaScriptCode

Event handler for Button, Checkbox, FileUpload, Layer, Password, Radio, Reset, Select, Submit, Text, TextArea, Window.

The onBlur event handler executes the specified JavaScript code or function on the occurrence of a blur event. This is when a window, frame or form element loses focus. This can be caused by the user clicking outside of the current window, frame or form element, by using the TAB key to cycle through the various elements on screen, or by a call to the window.blur method.

The onBlur event handler uses the following Event object properties.

type - this property indicates the type of event.
target - this property indicates the object to which the event was originally sent.

Examples

Code:
Enter email address <INPUT TYPE="text" VALUE="" NAME="userEmail" onBlur=addCheck()>

<script type="text/javascript" language="JavaScript">

function addCheck() {
     alert("Please check your email details are correct before submitting")
}

</script>
Explanation:

This example shows the use of the onBlur event handler to ask the user to check that the details given are correct. Note that the first line is HTML code.

See Also: