HTML onblurEvent Attribute

HTML 事件属性HTML Event Attributes

Examples

Perform validation when the user leaves the input field:

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

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the onblur event attribute


Definition and Usage

onblur triggers when an element loses focus.

onblur is often used for code validation (when the user leaves a form input field).

Tip:The opposite attribute of the onblur attributeonfocusattribute.


Differences Between HTML 4.01 and HTML5

None.


Syntax

<element onblur="script">

Attribute Values

Value Description
script Specifies the script to be executed when the onblur event is triggered


HTML 事件属性HTML Event Attributes Other Extensions