5. onblur

          The onblur event handler is used to track a user going away from an input element. “Goes away” means that the user may have clicked away, scrolled away, or clicked on other input elements. It is mainly used for checking if the input from the user is valid. One example is when you want to make sure that the user will input a value in a textbox. When the user clicks outside of the textbox, you can use this event to alert or display a pop-up that informs the user that they are required to input a value.

          The example below shows a code where a function is executed when the user clicks away from the text box. The user is alerted to go back to the textbox if the value is empty, else, the user is alerted

<form>

<label for="inpt">Type here: </label>

<input type="text" id="inpt" onblur="myFunction()">

</form>

<p id="demo"></p>

<script>

function myFunction() {

     var x = document.getElementById("inpt").value;

     if (x == ""){

                  alert("Go back to the textbox!");

            }

            else{

alert("Value accepted.");

}

}

</script>