Numeric checks (OpenInsight Specific)
At 04 SEP 2001 04:10:47PM a becker wrote:
The user enters a 2 digit number for the month on the form. I check for a length of 2 and for being between 01 and 12. I also check to see if it is a number.
Can anyone explain to me why .1 fails the num check BUT 1. DOES NOT FAIL THE NUM CHECK? It doesn't matter what the 1st number is, a period in the 2nd position does not fail the num check.
I'm just curious
Thanks
Andy Becker
Illinois State Lottery.
PS - The other message out there - I hit the tab key accidently before I was done. Sorry - someone can erase it.
At 04 SEP 2001 04:31PM Donald Bakke wrote:
Andy,
If I read your validation correctly, a .1 fails because it is less that 1 (and you are checking for values between 1 and 12). The 1. is accepted because it is a) a number, b) between 1 and 12, and c) it is two digits in length.
Wouldn't an integer and range (1-12) check be better for you? That way the decimal points will never be an issue.
At 04 SEP 2001 04:36PM Todd Meuth wrote:
It is because .1 is less than 1 - that is why that value would fail.
1. - 9. would all pass the validation because they are between 1 and 12 inclusive.
At 04 SEP 2001 05:14PM a becker wrote:
Thanks Don
I never thought of integer and range. I figured that num check should do the trick.
Silly me.
Andy
At 04 SEP 2001 09:08PM Scott, LMS wrote:
Hi All
You will be thrilled to know that engineering notation numbers also pass the num test eg 1E1 is 1 x (10 ^ 1) which is 10 and would have passed the original test…
Scott