HTML onblur Event Attribute HTML Reference



Example

Validate an input field when the user leaves it:

<input type="text" name="fname" id="fname" onblur="upperCase()">

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

1. Definition and Usage

The onblur attribute fires the moment that the element loses focus.

Onblur is most often used with form validation code (e.g. when the user leaves a form field).

Tip: The onblur attribute is the opposite of the onfocus attribute.


2. Differences Between HTML 4.01 and HTML5

None.


3. Syntax

<element onblur="script">

4. Attribute Values

ValueDescription
scriptThe script to be run on onblur

Relative articles