Email validation

Advertisements

Prev Tutorial Next Tutorial

Email validation

We can validate the email with the help of JavaScript. Here we check the condition related to any email id, like email if must have "@" and "." sign and also email id must be at least 10 character.

There are many criteria that need to be follow to validate the email id such as:

  • email id must contain the @ and . character
  • There must be at least one character before and after the @.
  • There must be at least two characters after . (dot).

Example

<html>
<head>
<script>
function email_validation() 
{  
var x=document.myform.email.value;  
var atposition=x.indexOf("@");  
var dotposition=x.lastIndexOf(".");  
if (atposition<1 || dotposition<atposition+2 || dotposition+2>=x.length){  
  alert("Please enter a valid e-mail address \n atpostion:"+atposition+"\n dotposition:"+dotposition);  
  return false;  
  }  
}  
</script>  

</script>
</head>
<body>
<form name="myform"  method="post" action="#" onsubmit="return email_validation();">  
Email: <input type="text" name="email"><br/>  
<input type="submit" value="register">  
</form></body>
</html>

Result

Email:

Prev Tutorial Next Tutorial

Advertisements

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet


Download Projects

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements