Fires when the object loses the input focus.
![]() |
Syntax
| HTML Attribute | <element onblur = "handler(event)"> |
|---|---|
| Event Property | object.onblur = handler; |
| addEventListener Method | object.addEventListener("blur", handler, useCapture) |
Event information
| Synchronous | No |
|---|---|
| Bubbles | No |
| Cancelable | No |
Event handler parameters
- pEvtObj [in]
-
Type: IHTMLEventObj
Standards information
- HTML 4.01 Specification, Section 18.2.3
Remarks
The onblur event fires on the original object before the onfocus or onclick event fires on the object that is receiving focus. Where applicable, the onblur event fires after the onchange event.
Use the focus events to determine when to prepare an object to receive or validate input from the user.
Switches focus away from the object on which the event is fired.
To invoke this event, do one of the following:
- Click the mouse on the document background or another control.
- Use the keyboard to navigate from one object to the next.
- Invoke the blur method when an object has focus.
- Switch focus to a different application or open a second window.
Examples
This example shows how to display the name of the object that has lost focus, that is, the object that fires the onblur event.
<html>
<body>
<input type="text"
name="txtFName"
value="First Name"
onblur="console.log(event.srcElement.name)">
<input type="text"
name="txtLName"
value="Last Name"
onblur="console.log(event.srcElement.name)">
<input type="text"
name="txtPhone"
value="Phone"
onblur="console.log(event.srcElement.name)">
</body>
</html>
See also
- a
- abbr
- address
- area
- audio
- b
- bdo
- blockQuote
- button
- canvas
- caption
- cite
- code
- custom
- dd
- del
- div
- dl
- document
- dt
- em
- embed
- fieldSet
- form
- hn
- hr
- i
- iframe
- img
- input type=button
- input type=checkbox
- input type=file
- input type=image
- input type=password
- input type=radio
- input type=reset
- input type=submit
- input type=text
- ins
- kbd
- label
- legend
- li
- media
- object
- ol
- option
- p
- pre
- q
- rt
- ruby
- s
- samp
- select
- small
- source
- span
- strong
- sub
- sup
- table
- tBody
- td
- textArea
- tFoot
- th
- tHead
- tr
- u
- ul
- var
- window
- Reference
- blur
- focus
- onfocusout
Send comments about this topic to Microsoft
Build date: 11/29/2012
