Testing a form text field for being an integer

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
davesearching
Forum Newbie
Posts: 2
Joined: Thu Jan 15, 2009 11:18 am

Testing a form text field for being an integer

Post 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.
watson516
Forum Contributor
Posts: 198
Joined: Mon Mar 20, 2006 9:19 pm
Location: Hamilton, Ontario

Re: Testing a form text field for being an integer

Post 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!)
Last edited by watson516 on Thu Jan 15, 2009 11:32 am, edited 1 time in total.
Reviresco
Forum Contributor
Posts: 172
Joined: Tue Feb 19, 2008 4:18 pm
Location: Milwaukee

Re: Testing a form text field for being an integer

Post 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
davesearching
Forum Newbie
Posts: 2
Joined: Thu Jan 15, 2009 11:18 am

Re: Testing a form text field for being an integer

Post by davesearching »

Thanks Reviresco and yes watson516 I did use Google and I don't appreciate useless sarcasm.
Post Reply