I have a text box on a web form. I require this to only be numeric...how would I go about this?
Woof
Printable View
I have a text box on a web form. I require this to only be numeric...how would I go about this?
Woof
Code:<script type="text/javascript">
<!--
function isNumericKey(e)
{
var k = document.all ? e.keyCode : e.which;
return ((k > 47 && k < 58) || k == 8 || k == 0);
}
function extractNumeric(str)
{
return str.replace(/\D/g,"");
}
// -->
</script>
<input type="text" onkeypress="return isNumericKey(event)" onchange="this.value=extractNumeric(this.value)" />