Re: ICQ # validation

From: Date: Tue, 04 Mar 2003 02:06:14 +0000
Subject: Re: ICQ # validation
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-138013@lists.php.net to get a copy of this message
Does it actually NEED a regexp? UNTESTED code: <? $icq = 2264532680; if( (is_int($icq)) && (strlen($icq) > 7) && (strlen($icq) < 9) ) { echo "yah"; } else { echo "nah"; } ?> FWIW, Are you SURE that all valid ICQ #'s are between 7 and 9 chars? Surely at some point they'll reach 10 chars, and *may* have started at 6? Justin on 04/03/03 6:00 AM, Liam Gibbs (liamgibbs@sympatico.ca) wrote: > Maybe I'm off my rocker, but I don't see how this can't work. I'm trying to > validate an ICQ number, and assuming a valid one is between 7 and 9 numbers. > My line of code is this: > > if(ereg("^[0-9]{7,9}$", $_REQUEST["icqnumber"])) { > print("a-okay!"); > } else { > print("error msg"); > } > > I've submitted the ICQ # 2264532680, but it validates. Any ideas? >

« previous php.general (#138013) next »