document.getElementById("id").addEventListener("blur", function() { alert("Hello World") });
<input type="text" id="fname" onblur="onBlurFuntion()"> <script> onBlurFuntion() { console.log("Input Focus Lost") } </script>