English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The onblur attribute is used to get or set the event handler function for the onBlur event of the current element
Perform format validation when the cursor leaves the input box:
<!DOCTYPE html> <html> <head> <title>HTML onblur event attribute usage (Basic Tutorial Website oldtoolbag.com)</title> <script> function upperCase() { var x=document.getElementById("fname").value document.getElementById("fname").value=x.toUpperCase() {} </script> </head> <body> <p>Enter your name and then move the cursor/Tab out of the input box:</p> Enter your English name (the mouse off will convert lowercase to uppercase): <input type="text" name="fname" id="fname" onblur="upperCase()"> </body> </html>Test and see ‹/›
IEFirefoxOperaChromeSafari
All major browsers support the onblur event attribute
The onblur attribute triggers when an element loses focus.
Onblur is most commonly used with form validation code (for example, when the user leaves a form field).
Tip: The opposite attribute of onbluronfocus attributes.
No difference.
<element onblur="script">
Value | Description |
---|---|
script | Specifies the script to be executed when the onblur event is triggered |