Feedback on: irt.org FAQ Knowledge Base Q332
Worth:
Worth reading
Technical:
Not technical enough
Comments:
The answer to Q332 shows how to pop up an alert when the user enters a non-number to a text box, but it doesn't then do anything to force the user to reenter the data. Obviously, a global flag could be set and checked, but a simple way would be to simply return the numeric value if it is okay or a zero if it is not and then invoke it via
...onChange="this.value=check(this.value);"...
Worth:
Worth reading
Length:
Just right
Technical:
Just right
Comments:
To check for a string that will return NaN when converting to a number:
if (((contents / contents) != 1) && (contents != 0))
will not work if contents is a string containing only spaces. You need something like this:
if ((contents / contents != 1) && (parseFloat(contents) != 0))