kendallkamikaze Posted April 16, 2009 Share Posted April 16, 2009 I have this code, it allows only numbers but I want to also not be able to use a space in it either, any suggestions? <SCRIPT TYPE="text/javascript"> <!-- // copyright 1999 Idocs, Inc. http://www.idocs.com // Distribute this script freely but keep this notice in place 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); // control keys if ((key==null) || (key==0) || (key== || (key==9) || (key==13) || (key==27) ) return true; // numbers else if ((("0123456789").indexOf(keychar) > -1)) return true; // decimal point jump else if (dec && (keychar == ".")) { myfield.form.elements[dec].focus(); return false; } else return false; } //--> </SCRIPT> Quote Link to comment Share on other sites More sharing options...
Psycho Posted April 16, 2009 Share Posted April 16, 2009 The function is returning false for me when using a space. Can you provide a working page with how you implemented the function? Quote Link to comment Share on other sites More sharing options...
kendallkamikaze Posted April 16, 2009 Author Share Posted April 16, 2009 wowwww totally weird..earlier today it was letting me space in it...now it isnt O.O I feel stupid now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.