Re: Detecing a Number

From: Date: Wed, 04 Dec 2002 21:46:42 +0000
Subject: Re: Detecing a Number
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-127041@lists.php.net to get a copy of this message
I have a repeating function to add. The user enters the number of how many numbers they want to add, then it repeats a form field. What I want to do is detect to make sure that the value they enter is a number. If not, don't do the do while loop and if it is, then go ahead and do it. How can I do this?
If you don't want to deal with any JavaScript, I suggest you try a simple ereg function like below: //$num = number entered by user if(ereg("[^0-9]+",$num): //returns true, a non numeric character was found else: //returns false, the string is all numbers endif; I haven't tested the above, so it may not work syntactically but the concept is the same... -- Kyle Gibson admin(at)frozenonline.com http://www.frozenonline.com/

« previous php.general (#127041) next »