Page 1 of 1

Testing a form text field for being an integer

Posted: Thu Jan 15, 2009 11:21 am
by davesearching
Hi,
How can I test that a text field from a form is an integer?
is_numeric is no good, neither is is_int.

Have tried looking for answer... no luck.

Re: Testing a form text field for being an integer

Posted: Thu Jan 15, 2009 11:28 am
by watson516
davesearching wrote:Hi,
How can I test that a text field from a form is an integer?
is_numeric is no good, neither is is_int.

Have tried looking for answer... no luck.
You tryed looking for answer did you? Next time, try google. Ah, the wonders of the internet. (Check out that first result, whoa!)

Re: Testing a form text field for being an integer

Posted: Thu Jan 15, 2009 11:31 am
by Reviresco
Assuming is_numeric or is_int don't work because you want to test it before the form is submitted?

Then you'll need javascript isInteger():

http://acmesoffware.com/acme/ExamplesJS ... nteger.asp

Re: Testing a form text field for being an integer

Posted: Thu Jan 15, 2009 12:32 pm
by davesearching
Thanks Reviresco and yes watson516 I did use Google and I don't appreciate useless sarcasm.