English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Manual de Referência do HTML

大全 de Tags do HTML

Atributo onblur do HTML

A propriedade onblur é usada para obter ou definir a função de manipulação de eventos do evento onBlur do elemento atual

HTML event attributes

Exemplo Online

Realizar validação de formato ao sair do campo de entrada do cursor:

<!DOCTYPE html>
<html>
<head>
<title>Uso do atributo onblur do HTML (TutorialBasico.net 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 to the input box outside:</p>
Enter your English name (the mouse away will be converted to uppercase): <input type="text" name="fname" id="fname" onblur="upperCase()">
</body>
</html>
Test and see ‹/›

Browser compatibility

IEFirefoxOperaChromeSafari

All major browsers support the onblur event attribute

Definition and usage

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.

HTML 4.01 and HTML5Differences between

No difference.

Syntax

<element onblur="script">

Attribute value

ValueDescription
scriptSpecifies the script to be executed when the onblur event is triggered
HTML event attributes