hi all,
i wrote code to block alphabets in a input text box, this is working perfectly in IE, but when I tried with mozilla fire fox its not working properly.
this is the code I used…
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN”
“
<html>
<head>
<script type=”text/javascript”>
if(navigator.appName!= “Mozilla”)
{
}
else{document.addEventListener(“keypress”,keyhit,true);}
onload = function(){
field = document.getElementById(‘number_field’)
field.onkeydown = keyhit
field.focus()
}
function keyhit(e)
{
thisKey = e ? e.which : window.event.keyCode
if(thisKey == ’65’ || thisKey == ’66’ || thisKey == ’67’ || thisKey == ’68’ || thisKey == ’69’ || thisKey == ’70’ || thisKey == ’71’ || thisKey == ’72’ || thisKey == ’73’ || thisKey == ’74’ || thisKey == ’75’ || thisKey == ’76’ || thisKey == ’77’ || thisKey == ’78’ || thisKey == ’79’ || thisKey == ’80’ || thisKey == ’81’ || thisKey == ’82’ || thisKey == ’83’ || thisKey == ’84’ || thisKey == ’85’ || thisKey == ’86’ || thisKey == ’87’ || thisKey == ’88’ || thisKey == ’89’ || thisKey == ’90’ )
{
event.returnValue = false;
alert (‘alphebets r not allowed’);
}
}
</script>
<title>increment field</title>
</head>
<body>
<form action=”” method=”post”>
<p><input type=”text” id=”number_field” name=”number_field” value=”0″></p>
</form>
</body>
</html>
please help me as soon as possible, thanks in advance…