Call a function after leaving input field

You can use onblur() or onfocusout(). It will call function once you click out of that text field.

Example:

function myFunction() {
    var x = document.getElementById("sometext");
    x.value = x.value.toUpperCase();
}
<input type="text" id="sometext" onfocusout="myFunction()">

Leave a Comment