HTML onblur event attribute
Example
Validate the input field when the user leaves the input field:
<input type="text" name="fname" id="fname" onblur="upperCase()">
Browser support
IE | Firefox | Chrome | Safari | Opera |
---|---|---|---|---|
All mainstream browsers support the onblur attribute.
Definition and usage
The onblur attribute triggers when the element loses focus.
onblur is commonly used in form validation code (e.g., when the user leaves a form field).
Tip:The onblur attribute is the opposite of the onfocus attribute.
Differences between HTML 4.01 and HTML5
None.
Syntax
<element onblur="script">
Attribute value
Value | Description |
---|---|
script | Script that runs when onblur occurs. |