java script code for email vilidaition

Here Some Full Example :)

<html>
<head>

<script language="javascript">

function validate(form_id,email,out) {

   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = document.forms[form_id].elements[email].value;
    
   if(reg.test(address) == false) {

      document.forms[form_id].elements[out].value='* Invalid Email Address';
      return false;
   }

	document.forms[form_id].elements[out].color='black';
   document.forms[form_id].elements[out].value='Valid Email Address :)';
   
   
}
</script>

</head>

<form id="frm" method="POST" action="">
	
	<p><input type="text" name="username" size="20"><p>
	<input type="text" name="password" size="20"><p>
	<input type="text" name="email" size="20" onkeypress="validate('frm','email','out');"><p>
	    <input id="out" style="border-style: none; border-color: inherit; border-width: 0px; background: white; font-family: tahoma; font-size: small; color: red; width: 141px;" disabled="disabled"/></td><p>
	&nbsp;&nbsp;<input type="submit" value="Submit" name="B1">
</form>

</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.