one of the best way to communicate with visitors and user is to provide a form. One of the most popular forms is the contact us forms. One of the essential fields to ask a user is for their email address. However, there are many people who just put garbage and not a real email address and you end up with spam or fake people's email address.

One way to confirm that users put a valid email address is with javascript, in my example if the user does not enter a vallid email address, they will received a popup window telling them that the email address they provided is not correct and to try again.

To teach you how to follow this step by step tutorial guide, start by opening you text editor and copy and paste the following code into your notepad:

<TITLE>Javascript Script Tutorial Check Email Address On Forms when submitted</TITLE>
<script language="JavaScript1.2">
var find_result
function form_email(){
var str=document.validation.email_address.value
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str))
alert("ERROR: Please enter a valid Email Address!")
return (find_result)

function checkbae(){
if (document.layers||document.getElementById||document.all)
return form_email()
return true
<style type="text/css">
.style2 {color: #0066FF}
.style3 {
   color: #009933;
   font-weight: bold;
.style5 {color: #0066FF; font-weight: bold; }
<strong>Javascript Script Tutorial Check Email Address On Forms when submitted
<? if($_POST[submit]){ ?>
<h1 align="center" class="style2">Congratulations: <span class="style3"><?php echo $_POST[email_address]; ?></span> is a valid Email</h1> <? }
else {?>
<br /><br /><br /><br /><form name="validation" onSubmit="return checkbae()" method="post">
  <table  border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#999999">
      <td bgcolor="#FFFFFF">Please enter a valid email address:<br></td>
      <td bgcolor="#FFFFFF"><input type="text" size=18 name="email_address"></td>
    <tr align="center">
      <td bgcolor="#FFFFFF">(example: [email protected])</td>
      <td bgcolor="#FFFFFF"><input type="submit" name="submit" value="Submit"></td>

<?php } ?>
<br />
<span class="style3">NOTE</span>: you must have javascript enabled in your browser for this to work, if you want to know how to enable javascript in your browser, <a href="">CLICK HERE </a><br /><br />
<div align="center">Turotial by <a href=""></a></div>
<hr size="2" noshade>
 <p>This Script is provided by <span class="style5"></span> - Support us by telling your friends about wallpaperama and help contribut to the open source by adding your knowledge of PHP, Linux, Mysql and more to others, just like this script.</p>
 <p>Thank You</p>
 <p class="style3">Wallpaperama Team</p>
 <p><a href="">&lt;&lt; Go Back</a> </p>
<p align="center">PHP Hosting by <a href=""></a> </p>

now save your file to whatever you want, i will be saving it as: javascript-valid-email

upload to your website and open it with your browser to see how it works

Our friends at have provided us with php hosting to show you a demo of how it would look like on your website:

if you own your website, and you have benefited or learned from this simple tutorial, we would like to ask you put our link in your site, or to exchange links with us.

Thank you

Wallpaperama Team