Thuộc tính onblur
<!DOCTYPE html> <html> <head> <script> function myFunction() { var x = document.getElementById("fname"); x.value = x.value.toUpperCase(); } </script> </head> <body> Enter your name: <input type="text" id="fname" onblur="myFunction()"> <p>When you leave the input field, a function is triggered which transforms the input text to upper case.</p> </body> </html>
Với thuộc tính onblur thì sau khi bạn nhập xong dữ liệu thì nó sẽ thay đổi ngay
Enter your name:
When you leave the input field, a function is triggered which transforms the input text to upper case.