How to use the lost focus attribute onblur in html

醉折花枝作酒筹
Release: 2023-01-05 16:07:44
Original
5260 people have browsed it

In HTML, the onblur attribute is triggered when an element loses focus. Syntax", onblur Often used for Javascript validation code, generally used in form input boxes.

The operating environment of this tutorial: Windows7 system, CSS3&&HTML5 version, Dell G3 computer.

The onblur attribute is triggered when the element loses focus. Commonly used in form validation code (such as when the user leaves a form field).

Note:

1. The onfocus attribute is opposite to the onblur attribute.

2. All major browsers support the onfocus attribute and onblur attribute.

Example

Validate when the user leaves the input field:

<script>
function upperCase()
{
var x=document.getElementById("fname").value
document.getElementById("fname").value=x.toUpperCase()
}
</script>
</head>
<body>
<p>请输入您的姓名,然后把焦点移动到字段外:</p>
请输入您的姓名(英文字符):<input type="text" name="fname" id="fname" onblur="upperCase()">
</body>
Copy after login

How to use the lost focus attribute onblur in html

Recommended learning:htmlvideo tutorial

The above is the detailed content of How to use the lost focus attribute onblur in html. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template