Javascript Email id validation Script

Tutorials Shared by the Internet Community

Advertisements


Javascript Email id validation Script

well this is a javascript email id validation script which will allow users to fill correct email id in your web form.

Statistics

  • Total Hits - 33405

  • Total Votes - 113 votes

  • Vote Up - 49 votes

  • Vote Down - 64 votes

  • Domain - webprogrammingscripts.blogspot.com

  • Category - Java Script/Validations

  • Submitted By - bholu

  • Submitted on - 2009-07-23 22:47:53

Description

01) it will show error messages if users dont enter @ or dot (.) sign in the email id<br /><br />2) if dot (.) sign or @ sign are written at the start or at the end it will show error message.it cannot be at the start.<br /><br />3) if they enter more than one dot(.) sign or @ sign in the email text box it will show an error. enter only one<br /><br />4) if users write email like abc@.com without writing some text after @ sign then it will show error messages that dot (.) sign should not be written after @ sign some text should be there.<br /><br />5) this script will help u in all ur validation problems in your email id validation problems .<br /><br />a very good handy script for all users for their website form validation purpose.<br /><br /><script language="javascript"><br />function check()<br />{<br />if (document.f1.a1.value=="")<br />{<br />alert ("enter ur email id to continue")<br />return false;<br />}<br />if (document.f1.a1.value.indexOf("@")==-1 || document.f1.a1.value.indexOf(".")==-1)<br />{<br />alert ("enter ('@') &amp; ('.') sign to continue")<br />return false;<br />}<br /><br />var atpos=f1.a1.value.indexOf('@',0)<br />if (atpos==0)<br />{<br />alert ("email address must not start with ('@')")<br />return false;<br />}<br /><br /><br /><br />if (document.f1.a1.value.indexOf('@',atpos + 1) > -1)<br />{<br />alert ("no 2 @sign in email id")<br />return false;<br />}<br /><br />if (document.f1.a1.value.indexOf('@.',0) != -1)<br />{<br />alert ("period should not immediately follow ('@') sign")<br />return false;<br />}<br />if (document.f1.a1.value.indexOf('..',0) != -1) {<br />alert(" two periods must not be adjacent in email address");<br />return false;<br />}<br />if (document.f1.a1.value.indexOf('.@',0) != -1)<br />{<br />alert ("('.')sign only after ('@')sign")<br />return false;<br />}<br />}<br /></script><br /><br /><body><br /><form name="f1" onSubmit="return check()"><br />email id:<input type="txt" name="a1"><br /><input type="submit" value="submit"><br /></form><br /></body>    More detail...


Broken  |   Tweet  |   Facebook  |     |   Save  |   Liked  |   Down

Advertisements