Re: limit form input digits
| From: | Marek Kilimajer | Date: | Wed, 07 May 2003 12:40:49 +0000 |
| Subject: | Re: limit form input digits | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-146658@lists.php.net to get a copy of this message | ||
The regex returns true if there are at least 2 nondigits next to each other. If you want to limit the number of digits to 2, use
if (ereg ("([0-9]{3})", $incre)) {
echo "bad input";
} else {
echo "Printing now ...<br>";
}
or more simple
if ($incre > 99)
in html use
<input type="text" maxlength="2" size="2" .... >
Malcolm wrote:
Hello All, I'm trying to limit to 99 the amount of times this prints ; if (ereg ("([^0-9]{2})", $incre)) { echo "bad input"; } else { echo "Printing now ...<br>"; } Reading the manual and the comments I thought the {2} would do that, but it doesn't. I have set the form field size to two but that isn't working either, you can still put more than two numbers in the field even though they don't show. The {2} does keep letters out but how can I limit the input to two digits ?