form validation self study
<p>please help. I'm not asking you to create the program just please tell me what I'm missing. This is for self studying. I am trying to make a javascript program that would do this:
    1. alert user if no name or email had been created
    2. email data must contain an @ sign and at least one dot (.). Also, the @ must not be the first character of the email address, and the last dot must be present after the @ sign, and minimum 2 characters before the end.
 My code:</p>

<pre><code> &lt;html&gt;
 &lt;head&gt;
 &lt;script type="text/javascript"&gt;

 function validateForm1()
 {
 var y=document.forms["myForm"]["email"].value;
 var atpos=y.indexOf("@");
 var dotpos=y.lastIndexOf(".");
 var x=document.forms["myForm"]["fname"].value;
 if (x==null || x=="" ||  y=="")
 {
 alert("First name and Email must be filled out");
 return false;
 }
 else if (atpos&lt;1 || dotpos&lt;atpos+2 || dotpos+2&gt;=x.length)

 {
 alert("Not a valid e-mail address");
 return false;
}
}

 &lt;/script&gt;
 &lt;/head&gt;

 &lt;body&gt;

&lt;form name="myForm" action=# onsubmit="return validateForm1()" method="post"&gt;
 First name: &lt;input type="text" name="fname"&gt;&lt;br/&gt;
Email: &lt;input type="text" name="email"&gt;&lt;br/&gt;
&lt;input type="submit" value="Submit"&gt;
&lt;/form&gt;



&lt;/body&gt;

&lt;/html&gt;
</code></pre>
