Program Code- Email validation

This code is written in javascript. For that, you need to set script language <script language=”javascript”> and the HTML file cloud opened on your browser.

The output will check the entered mail is email is valid or not. If the email is not valid it shows a message box “Invalid Email id please enter correct format” otherwise it is show “valid mail”.

<html>
<head>
<title>Check Email Address</title>
<script language="javascript">
function checkEmail(inputvalue)
{	
    var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
    if(pattern.test(inputvalue))
    {         
		alert("Valid Email");   
    }
    else
    {   
		alert("Invalid Email id please enter correct format"); 
    }
}
</script>
</head>
<body>
<form name="signupform"> <!--The HTML form tag is required when you want to collect information that visitors provide. For example, you may want to collect specific data from visitors, such as name, email address, and password. -->
<h1> Email Validation </h1>
<br>
<br>
Input your email: <input name="email" type="text" > 
<!-- The input type was email it's used for put a text in email type -->
<input  type="submit" value="Check" onClick="checkEmail(document.signupform.email.value)"> 
<!-- The submit was check the email and call the function onclick -->  
</form> 
</body>
</html>

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.