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.

01-18-2006, 08:31 PM
You could do something like this -

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.

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

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


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

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum