Wednesday, August 6, 2008

Ow To Play Undf Files

Javascript: Allow only input numbers

There is often that we have a text field in which we that only certain characters can be entered (in our example only numbers and spaces).

Then I leave the code to implement this.




/ / This function lets you enter numeric values \u200b\u200bonly and spaces in a numeric field
/ / invocation is: onkeypress = "return validarNumericOnly (event);"
/ / Use doBeep function to generate an alert the user when entering a value validarNumericOnly
wrong function (e) {var keyCode
;
var returnVal = true;

if (window.event) {e = window.event
;
keyCode = e.keyCode;} / / arrow left = 29 / / arrows
der = 28 / / arrow up = 30 / / down arrows
= 31 / / backspace = 8 / / DELETE = 127
/ / space = 32 / / TAB = 9 / / ALL NUMBERS and SPACE if ((e.keyCode> = 48 & & e.keyCode
 = 28 & & e.keyCode 


In another post I published the code to make the Beep!


0 comments:

Post a Comment