What does the following JavaScript code do?
<head id="Head1" runat="server">
<title></title>
<script type="text/javascript">
function validate() {
var chk = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var ok = "yes";
var temp;
var field1 = document.getElementById("t1");
var field = field1.value.substring(field1.value.length - 1, field1.value.length);
if (chk.indexOf(field) == "-1") {
alert("error");
field1.value = (field1.value).slice(0, field1.value.length - 1);
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<input type="text" id="t1" onkeyup="validate()" onkeypress ="validate()"/>
</form>
</body>
Answer
Correct Answer: The code will cause an error alert to be displayed if a non alphabet character is entered.
Explanation:
Note: This Question is unanswered, help us to find answer for this one