This is a simple sample of similar thing:
Here is how to filter out:
<html>
<head>
<script type="text/javascript"><!--
function filterDigits(eventInstance) {
eventInstance = eventInstance || window.event;
key = eventInstance.keyCode || eventInstance.which;
if ((47 < key) && (key < 58) || key = 45 || key == 8) {
return true;
} else {
if (eventInstance.preventDefault) eventInstance.preventDefault();
eventInstance.returnValue = false;
return false;
}
}
--></script>
</head>
<body">
<input type="text" onkeypress="filterDigits(event)"/>
</body>
</html>
Pay attention that the key code 8 (backspace) is allowed. By some historical reason, this key is considered as a character, so it should be specifically allowed through the filter.
—SA