ใช้ onblur แอตทริบิวต์รันสคริปต์เมื่อองค์ประกอบสูญเสียโฟกัสใน HTML คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อใช้งาน onblur แอตทริบิวต์ −
ตัวอย่าง
<!DOCTYPE html>
<html>
<body>
<p>Type text below!</p>
Country: <input type = "text" name = "myid" id = "myid" onblur = "display()">
<script>
function display() {
var str = document.getElementById("myid");
str.value = str.value.toUpperCase();
}
</script>
</body>
</html>