This event will be fired when the element loses focus. Mostly it is used with the form validation code(e.g. with the input field in a form). onfocus event is the opposite to the onblur attribute.
Syntax :
<element onload="script">
Example :
HTML Code :
<!DOCTYPE html>
<html>
<body>
Name: <input type="text" name="fname" id="fname" onblur="onblurFunction()">
<p>When you leave the input field, a function is fired which convert the input text to upper case. </p>
</body>
</html>
Javascript Code :
<script>
function onblurFunction() {
var x = document.getElementById("fname");
x.value = x.value.toUpperCase();
}
</script>
Output:
When you leave the input field, a function is fired which convert the input text to upper case.
e.g :
if you enter any text(i.e mukesh) inside the input field, then it convert into upper case i.e. MUKESH
0 Comment(s)