<!DOCTYPE html>
<html lang="en-US">
<body>
<p>Type your Name and leave the input field.</p>
<input type="text">
<script>
var x = document.getElementsByTagName("input")[0];
x.addEventListener("blur", function(){
alert("Input field lost focus");
});
</script> </body>
</html>