javascript validate @ sign in text area
<p>Im trying to do an assignment and having trouble getting code to validate. Problem is I need the email text box in form to check if "@" is present, but also in same form I need to check if name text box is empty or not. I can only get one of them to work at once.</p>

<p>This is my coding.</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
  &lt;head&gt;
    &lt;title&gt;Weclome to the Recipe Collection Website&lt;/title&gt;
    &lt;script&gt;
    function validateForm()
    {
    var x=document.forms["myForm"]["name"].value;
    if (x==null || x=="")
     {
     alert("Name text box must be filled out");
     return false;
     }
    &lt;/script&gt;
    &lt;script&gt;
    function checkEmail()
    {
    var y=document.forms["myForm"]["email"].value;
    var atpos=y.indexOf("@");
    var dotpos=y.lastIndexOf(".");
    if (atpos&lt;1 || dotpos&lt;atpos+2 || dotpos+2&gt;=y.length)
     {
     alert("Not a valid e-mail address");
     return false;
     }
    }
    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;form name="myForm" onsubmit="return validateForm()" method="post"&gt;
        Name: &lt;input type="text" name="name"&gt;&lt;br&gt;
        Email: &lt;input type="text" name="email"&gt;&lt;br&gt;
        Number of recipes previously submitted: &lt;input type="radio" name="recipes" value="0"&gt;0&lt;br&gt;
        &lt;input type="radio" name="recipes" value="1-2"&gt;1-2&lt;br&gt;
        &lt;input type="radio" name="recipes" value="3-4"&gt;3-4&lt;br&gt;
        &lt;input type="radio" name="recipes" value="5+"&gt;5+&lt;br&gt;
        Have you ever submitted recipes to another site?: &lt;input type="radio" name="othersite" value="yes"&gt;Yes&lt;br&gt;
        &lt;input type="radio" name="othersite" value="no" checked&gt;No&lt;br&gt;
        &lt;input type="submit" value="Submit"&gt;
    &lt;/form&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Is this way off?</p>

<p>Thanks for any help.</p>
