...

View Full Version : Allowing numeric numbers only



Big Kahuna
01-18-2006, 07:50 PM
I have a text field that requires a users extension and only 0-9 is acceptable with no alpha characters allowed. How can I do this?

Thanks in advance.

mark87
01-18-2006, 08:31 PM
You could do something like this -
http://www.cs.tut.fi/~jkorpela/forms/check2.html

arnyinc
01-18-2006, 09:52 PM
<input type="text" onkeyup="if(isNaN(this.value)) { this.value=this.value.substring(0, this.value.length-1) }">

Edit: Actually, this is probably a better solution than the one I posted above here.

<html>
<head>
<script language="javascript">
function checkNum(object) {
object.value=object.value.replace(/\D*/g, "");
}
</script>
</head>

<body>
<input type="text" id="usage" onkeyup="checkNum(this);">
</body>

</html>

vwphillips
01-18-2006, 10:16 PM
solution already posted



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum