Jump to content

Email Verification - No Number In Position 1 Of Field


arccomp

Recommended Posts

I have this line of code to check for email. I need to make sure it fails if there is a number in the first location. I am adding the email address to a linux server from the form and the linux server rejects the email address if there is a number in the first location of the text field. Any help would be appreciated.

 

public function isValidEmail($in_email)

{

if (empty($in_email))

{

return false;

}

else

{

if (!preg_match("(^[-\w\.]+@([-a-z0-9]+\.)+[a-z]{2,4}$)i", $in_email))

{

return false;

}

else

{

return true;

}

}

}

There was just a topic solved on this subject

http://forums.phpfreaks.com/topic/270298-if-not-email-address/#entry1390268

 

If you only want to check the first character then use braces to grab it and validate it

if(is_int($emailInput[0]))

There was just a topic solved on this subject

http://forums.phpfre...s/#entry1390268

 

If you only want to check the first character then use braces to grab it and validate it

if(is_int($emailInput[0]))

 

Thanks - will try this - sort of new at php. Will let you know. It seems the problem you refered to me above is different so I was a little confused by that.

Surely you can do better than "it breaks the site".

The page with the form that includes and calls this function goes to a white screen. Trying to figure out if I can debug it.

 

This is the code:

 

public function isValidEmail($in_email)

{

if (is_int($in_email[0]))

{

return false;

}

else

{

if (empty($in_email))

{

return false;

}

else

{

if (!preg_match("(^[-\w\.]+@([-a-z0-9]+\.)+[a-z]{2,4}$)i", $in_email))

{

return false;

}

else

{

return true;

}

}

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.