Here is some javascript I use to make it so that the user can only enter numbers:

Code:
<script type="text/javascript">

function numbersonly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;

else if ((("0123456789+").indexOf(keychar) > -1))
   return true;

else if (dec && (keychar == "."))
   {
   myfield.form.elements[dec].focus();
   return false;
   }
else
   return false;
}
Then my button tag looks like this: <input type="text" name="IdNumber" onKeyPress="return numbersonly(this, event)" size="40" maxlength="15">
Maybe you can change the code to suit your goal?? I think.

Last edited by shabbir; 25Jan2010 at 17:08.. Reason: Code blocks