Simple Email Form validation with Javascript

25Mar09

If you want to validate an email field using simple and easy Javascript without any fancy looks then here is the function that can help you…

Click more to find out the Javascript function function echeck(emailStr) { var at="@"; var dot="."; var lat=emailStr.indexOf(at); var lstr=emailStr.length; var ldot=emailStr.indexOf(dot); if (emailStr.indexOf(at)==-1){ alert("Invalid E-mail ID") return false } if (emailStr.indexOf(at)==-1 || emailStr.indexOf(at)==0 || emailStr.indexOf(at)==lstr){ alert("Invalid E-mail ID") return false } if (emailStr.indexOf(dot)==-1 || emailStr.indexOf(dot)==0 || tr.indexOf(dot)==lstr){ alert("Invalid E-mail ID") return false } if (emailStr.indexOf(at,(lat+1))!=-1){ alert("Invalid E-mail ID") return false } if (emailStr.substring(lat-1,lat)==dot || emailStr.substring(lat+1,lat+2)==dot){ alert("Invalid E-mail ID") return false } if (emailStr.indexOf(dot,(lat+2))==-1){ alert("Invalid E-mail ID") return false } if (emailStr.indexOf(" ")!=-1){ alert("Invalid E-mail ID") return false } return true }

Advertisements


No Responses Yet to “Simple Email Form validation with Javascript”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: