Write a JavaScript program to demonstrate focus and blur events.
<html>
<head>
<title>Changing focus of form text element</title>
</head>
<body>
<input type="text" id="txt1"/><br/>
<input type="text" id="txt2"/>
<script>
var t1 = document.getElementById('txt1');
t1.onfocus = focus;
t1.onblur = blur;
var t2 = document.getElementById('txt2');
t2.onfocus = focus;
t2.onblur = blur;
t1.focus();
function focus()
{
this.value = "In Focus";
}
function blur()
{
this.value = "Focus Lost";
}
</script>
</body>
</html>
