Javascript For Only Allowing Decimals or Integers
To prevent input of other non decimal/integer characters, aka not 0-9 or '.' to a text box you want to look for the keycodes client side. Having a keypress event on the server side wold be inefficient and silly when you can do it in client side. If you are trying to validate input you will also need to check server side.
This fix in my case was mainly for a minor tool that does not access anything outside of itself. If the user is intelligent enough to turn off Javascript then they will know why they it does not work. The tool is hardly used, but if it turns out non-hackers are able to bypass the Javascript and keep getting errors then I will consider doing more server side validation. So good enough for now.
ref: http://www.codeproject.com/Questions/425670/Textbox-only-for-Numeric-decimal-values
This fix in my case was mainly for a minor tool that does not access anything outside of itself. If the user is intelligent enough to turn off Javascript then they will know why they it does not work. The tool is hardly used, but if it turns out non-hackers are able to bypass the Javascript and keep getting errors then I will consider doing more server side validation. So good enough for now.
ref: http://www.codeproject.com/Questions/425670/Textbox-only-for-Numeric-decimal-values
Comments
Post a Comment