What does the following JavaScript code do?
<html>
<body>
<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>
<input type="text" id="t1" onkeyup="validate()" onkeypress ="validate()"/>
</body>
</html>
Correct Answer: The code will cause an error alert to be displayed if a numeric character is entered, and the numeric character is removed.
Explanation:
Note: This Question is unanswered, help us to find answer for this one
More JavaScript MCQ Questions
JavaScript MCQs | Topic-wise