N
Nicolae Fieraru
Hi All,
I have some javascript code and I try to filter out any characters (which
are not digits or delete) from an input element in a form.
Here is the code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> JavaScript </TITLE>
<script language="JavaScript" type="text/JavaScript">
<!--
function filter(evt) {
var keyCode = evt.which ? evt.which : evt.keyCode;
return (keyCode >= '0'.charCodeAt() && keyCode <= '9'.charCodeAt()) ||
keyCode == 8;
}
-->
</script>
</HEAD>
<BODY>
<form method="post" action="" name="form">
<input maxLength=5 size=4 name='25' value="" ONKEYDOWN="return
filter(event)">
</form>
</BODY>
</HTML>
The problem with this code is that it doesn't accept input from the numpad.
Is there a way to make it work with the numpad as well?
Regards,
Nicolae
I have some javascript code and I try to filter out any characters (which
are not digits or delete) from an input element in a form.
Here is the code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> JavaScript </TITLE>
<script language="JavaScript" type="text/JavaScript">
<!--
function filter(evt) {
var keyCode = evt.which ? evt.which : evt.keyCode;
return (keyCode >= '0'.charCodeAt() && keyCode <= '9'.charCodeAt()) ||
keyCode == 8;
}
-->
</script>
</HEAD>
<BODY>
<form method="post" action="" name="form">
<input maxLength=5 size=4 name='25' value="" ONKEYDOWN="return
filter(event)">
</form>
</BODY>
</HTML>
The problem with this code is that it doesn't accept input from the numpad.
Is there a way to make it work with the numpad as well?
Regards,
Nicolae