Validate an input field when the user leaves it:
More "Try it Yourself" examples below.
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.
Event Attribute | |||||
---|---|---|---|---|---|
onblur | Yes | Yes | Yes | Yes | Yes |
None.
Value | Description |
---|---|
script | The script to be run on onblur |
Supported HTML tags: | All HTML elements, EXCEPT: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, and <title> |
---|
Using "onblur" together with the "onfocus" attribute:
HTML DOM reference: onblur event