On Wed, 2003-10-22 at 09:48, Wade Preston Shearer wrote:
> i have a form where the user must enter a 10 digit number, with no 
> exceptions.
> 
> so, i am trying to add some code to the PHP script that will validate 
> that the entered string is good... and, if good... proceed, but if 
> bad... print out an error with instructions.
> 
> so far, i am using strlen to make sure that it is indeed 10 characters 
> long.
> 
> next, i am not sure how to proceed. preg_match is a good way to check 
> for characters, but it doesn't seem very good to have a preg_match line 
> for every conceivable character other than numbers.
> 
> is there a string search function that says simply checks if the 
> characters within are numeric?

You want to learn regular expressions. It will make your life better.
They are extremely flexible. Not only can the perform validation, but
also transformation. I don't feel like reading the PHP documentation at
the moment, so you'll have to adapt for implementation quirks, but you
want something like /^\d{10}$/.

-- 
Stuart Jansen <[EMAIL PROTECTED], AIM:StuartMJansen>

Programming in Java feels like C without the sense of accomplishment.

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
newbies mailing list
[EMAIL PROTECTED]
http://phantom.byu.edu/cgi-bin/mailman/listinfo/newbies

Reply via email to