- Oct 9, 2002
- 28,298
- 1,236
- 136
Anyone ever have to validate a field for something like a 4-digit numeric PIN?
Users input a 4-digit unsigned whole-number value into a textbox. I want to validate with the following criteria:
After some Google-ing, I see that there are PHP functions to make sure a string is numeric, but it happily allows decimals, signs, and exponents.
I can do a lot of this checking manually, but I get the feeling that there's some super-easy way to do it that I'm just missing.
Users input a 4-digit unsigned whole-number value into a textbox. I want to validate with the following criteria:
- Make sure LEN=4, including leading zeroes.
- I do not want leading zeroes added automatically when LEN<4.
- If LEN != 4, user will be prompted to make sure number was entered correctly.
- I do not want to eliminate leading zeroes.
- The characters are numeric-only.
- The value is a whole number integer.
- The value does not have a sign or exponent.
After some Google-ing, I see that there are PHP functions to make sure a string is numeric, but it happily allows decimals, signs, and exponents.
I can do a lot of this checking manually, but I get the feeling that there's some super-easy way to do it that I'm just missing.
Last edited:
