June 12, 2009

1 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. below are the features of this script which will allow users to enter correct email id like example yoursite@website.com in correct form otherwise it will show error messages to users to enter correct email id.

the features of this scripts are as follows:


01) it will show error messages if users dont enter @ or dot (.) sign in the email id

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.

3) if they enter more than one dot(.) sign or @ sign in the email text box it will show an error. enter only one

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.

5) this script will help u in all ur validation problems in your email id validation problems .

a very good handy script for all users for their website form validation purpose.

do try and reply soon with your comments.



<script language="javascript">
function check()
{
if (document.f1.a1.value=="")
{
alert ("enter ur email id to continue")
return false;
}
if (document.f1.a1.value.indexOf("@")==-1 || document.f1.a1.value.indexOf(".")==-1)
{
alert ("enter ('@') & ('.') sign to continue")
return false;
}

var atpos=f1.a1.value.indexOf('@',0)
if (atpos==0)
{
alert ("email address must not start with ('@')")
return false;
}



if (document.f1.a1.value.indexOf('@',atpos + 1) > -1)
{
alert ("no 2 @sign in email id")
return false;
}

if (document.f1.a1.value.indexOf('@.',0) != -1)
{
alert ("period should not immediately follow ('@') sign")
return false;
}
if (document.f1.a1.value.indexOf('..',0) != -1) {
alert(" two periods must not be adjacent in email address");
return false;
}
if (document.f1.a1.value.indexOf('.@',0) != -1)
{
alert ("('.')sign only after ('@')sign")
return false;
}
}
</script>

<body>
<form name="f1" onSubmit="return check()">
email id:<input type="txt" name="a1">
<input type="submit" value="submit">
</form>
</body>




1 comments:

Bibek Subedi said...

Good article....really helpful....
i tried it and it works well..thank u for ur great post..
do not forget visiting my site http://compechnepal.blogspot.com and follow me

Post a Comment

Blogger Themes

 
Powered by Blogger