[wd_asp elements=’search’ ratio=’100%’ id=1]

Check valid email field

20th July 2013

Javascript

javascript category codehaven

Email Address:

Basic code
Add this to your input
onblur="checkEmail()"

Any field with an id of emailaddress will be checked if this function is called.

Alternative

// Check Valid or Invalid email when user enters email in email input field.
if ($formfield == "email") {
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $value)) {
echo "Invalid email";
} else {
echo "Valid";
}