Javascript for validating numbers in textbox

This one-line code seemed to return a response of "false" even if a single integer was entered.

There are many ways in which you could implement this check.

You need to still allow basic operational keys for a textbox – navigation keys, backspace and delete, tab/shift tab and the Enter key - to work or else the textbox will feel very different than a standard text box.

Yes there are plug-ins that allow masked input easily enough but most are fixed width which is difficult to do with plain number input.

When a key is pressed the handler is fired and the key Code of the event object is sent.

Recall that j Query normalizes the Java Script Event object between browsers.


Leave a Reply