Forum Moderators: coopster

Message Too Old, No Replies

strlen and parenthesis

         

tekomp

10:10 pm on Jan 24, 2006 (gmt 0)

10+ Year Member



Hi,

I'm doing some form validation on a phone number field and it's returning invalid when I have a parenthesis as the first character of my phone number. Here's the code I have:


$bus_phone = $_POST["bus_phone"];

if(strlen($bus_phone < 10))
{
$error_msg .= "<li>Your phone number is invalid</li>";
$errors['bus_phone'] = 1;
}

This returns invalid: (234)234-4324

Does strlen not work with parenthesis or something? Thanks.

tekomp

10:26 pm on Jan 24, 2006 (gmt 0)

10+ Year Member



Nevermind this one. I had the parenthesis in the wrong spot.

coopster

10:30 pm on Jan 24, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Exactly.
if (strlen($bus_phone) < 10)

Nice catch ;)