This is a discussion on "PHP integer form validation" within the PHP Forum section. This forum, and the thread "PHP integer form validation are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
PHP integer form validation
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
||||
|
PHP integer form validation
I'm making a couple of validations for a form. One of them checks to see if the number is an integer. I figured I can just use isint(). Wrong. Since the POST data from the form is a string, isint won't work. And isnumerical() will return yes if it has a decimal point (float) but I don't want that. So how do I check to make sure a number string is an int and not a float?
__________________
echo "Take it easy, ".$CloudedVision; .links { site: other-road-design; blog: only-nerds-allowed; project: resource-fish; organization: ARMIES6; } <quote>"I think it's wrong that only one company makes the game Monopoly" - <name>Steven Wright</name></quote>
Last Blog Entry: More Cheat Sheets (Jul 12th, 2008)
|
|
|
|
|||
|
Re: PHP integer form validation
One of the many possible solutions:
if( preg_match( '/^\d+$/', $yourStringVar ) ) { ... } |
|
||||
|
Re: PHP integer form validation
Last Blog Entry: 10 Reasons Why My Laptop Is Better Than Your Girlfriend (Dec 15th, 2007)
|
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Form validation help! | psycho wolvesbane | JavaScript Forum | 16 | Feb 12th, 2008 16:40 |
| Form Validation | cjrollo | Flash & Multimedia Forum | 0 | Feb 22nd, 2007 17:33 |
| PHP Form Validation ??? | j4mes_bond25 | PHP Forum | 2 | May 31st, 2006 23:08 |
| Form Validation Help | gajlehab | PHP Forum | 7 | Dec 13th, 2005 19:40 |
| Form validation | brittny | JavaScript Forum | 2 | Jul 8th, 2005 19:46 |