Showing posts with label Check email format in javascript. Show all posts
Showing posts with label Check email format in javascript. Show all posts

Friday, April 13, 2018

Check Email Format in JavaScript

Here is a simple script that I wrote using JavaScript to check if the given email format by our user is valid or not.

I am currently accepting programming work, it project, school programming projects , thesis and capstone projects, IT consulting work and web development work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.



Program Listing

email.htm


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Check Email Format</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript">
function checkemail( ){
if(document.myForm.email.value.length!=0){
if(document.myForm.email.value.charAt(0)=="."||
   document.myForm.email.value.charAt(0)=="@"||
   document.myForm.email.value.indexOf('@',0)==-1||
  document.myForm.email.value.indexOf('.',0)==-1||
          document.myForm.email.value.lastIndexOf('@')==document.myForm.email.value.length-1||
        document.myForm.email.value.lastIndexOf('.')==document.myForm.email.value.length-1 ) {
alert("E-mail format wrong!");
document.myForm.email.focus();
return false;
}
else {
alert("Email Format Correct!");}
}
else{
alert("Email cannot be empty!");
document.myForm.email.focus();
return false;
}
return false;
}
</script>
</head>
<body>
<center>
  <h2>Check E-mail Format </h2>
  <hr>
</center>
<form name="myForm" method="POST" action onSubmit="return checkemail()">
  <div align="center">E-mail: 
    <input type="text" name="email" id="email" size="20">
    &nbsp;
    <input type="submit" value="Submit" >
  </div>
</form>
</body>
</html>