[thelist] output value
Scott Brady
evolt at scottbrady.net
Fri Jan 24 08:09:01 CST 2003
Morgan (and thelist in general).
I'd like to apologize for my defensive post yesterday regarding the use of Evaluate() vs. Form[] notation. I was in a fairly pissy mood and got hypersensitive about the use of the word "wrong".
I think everyone learns new things on this list at some point or another, and I shouldn't have gotten so defensive. What's funny is that I used the Form[] notation where I would have used Evaluate() yesterday, so it turned out well.
What was I pissy about? See my tip for the source of my frustration.
<tip author="Scott Brady" type="javascript">
If you're dealing with number strings with leading 0's, Javascript interprets the number as a base-8 (octal) number (if it starts with "0x" it interprets it as a hexadecimal number).
This can cause problems if you're trying to evaluate the number string, but only for the numbers "08" and "09" [for two-digit numbers].
For example, I was evaluating a form field that was a time (such as "12:15" or "16:08") and wanted to make sure the numbers were valid for a time (first part had to be 23 or less; second part had to be 59 or less). However, if the minutes are "08" or "09", parseint()-ing those values gets you "NaN" or similarly useless results. 00 - 07 work out ok, because in octal, they're still 0 - 7.
So, to get around this, I had to trim any leading 0's.
</tip>
Scott Brady
More information about the thelist
mailing list