Java Reference
In-Depth Information
}
} else {
alert("Thanks for completing the form " + txtName.value);
}
}
function txtAgeBlur(e) {
var target = e.target;
if (isNaN(target.value)) {
alert("Please enter a valid age");
target.focus();
target.select();
}
}
function txtNameChange(e) {
alert("Hi " + e.target.value);
}
myForm.txtName.addEventListener("change", txtNameChange);
myForm.txtAge.addEventListener("blur", txtAgeBlur);
myForm.btnCheckForm.addEventListener("click", btnCheckFormClick);
</script>
</body>
</html>
After you've entered the text, save the file as ch11 _ example4.html and load it into your web browser.
In the text box shown in Figure 11-5, type your name. When you leave the text box, you'll see
Hi yourname appear in an alert box.
figure 11-5 
Search WWH ::




Custom Search