Very little Javascript code is needed to perform the following numbers only formatting for input type="text" ...
Try entering anything but numbers in the textbox below. Also, change the value of maxwidth and experiment. Feel free to view this pages source code to see the Javascript code for yourself.