Javascript form validation is not working properly
<p>JS is not working properly. I don't know why. can anyone help me? Here is my code...</p>

<pre><code>function validate() {
    if(document.contactform.name.value==''){
        alert('Fill the Input name');
        name.focus();
        return false;
    }
    if(document.contactform.email.value==''){
        alert('Fill the Input email');
        email.focus();
        return false;
    }
    if(document.contactform.email.value!=''){
        if(!checkEmail(email.value)){
            alert('Please specify your correct Email!');
            email.focus();
            return false;           
        }       
    }
    if(document.contactform.mobile.value==''){
        alert('Fill the Input mobile');
        mobile.focus();
        return false;
    }
    if(document.contactform.mobile.value!=''){
        if(!IsNumeric(mobile.value)){
            alert('Please specify your correct Mobile Number!');
            mobile.focus();
            return false;           
        }       
    }
    if(document.contactform.subject.value==''){
        alert('Fill the Input Subject');
        subject.focus();
        return false;
    }   
    if(document.contactform.message.value==''){
        alert('Fill the Input description');
        message.focus();
        return false;
    }   
    if(!document.contactform.agree.checked){
        alert('Please check the terms and conditions'); 
        return false; 
    } 
    else{
        return true;
    }
}
</code></pre>

<p>Here is my html...</p>

<pre><code>&lt;form name="contactform" id="form" class="form" action="newmail.php" onsubmit="return validate();" method="post"&gt;
&lt;TABLE align="center"  border="0"&gt;
 &lt;TR&gt;&lt;TD align="right"&gt; &lt;b&gt;Name :&lt;/b&gt;&lt;/TD&gt;&lt;TD align="left"&gt;&lt;input type="text" name="name" id="name" /&gt;&lt;/TD&gt;&lt;/TR&gt;
 &lt;TR&gt;&lt;TD align="right"&gt; &lt;b&gt;Email :&lt;/b&gt;&lt;/TD&gt;&lt;TD align="left"&gt;&lt;input type="text" name="email" id="email" /&gt;&lt;/TD&gt;&lt;/TR&gt; 
 &lt;TR&gt;&lt;TD align="right"&gt; &lt;b&gt;Mobile :&lt;/b&gt;&lt;/TD&gt;&lt;TD align="left"&gt;&lt;input type="text" name="mobile" id="mobile" /&gt;&lt;/TD&gt;&lt;/TR&gt; 
 &lt;TR&gt;&lt;TD align="right"&gt; &lt;b&gt;subject :&lt;/b&gt;&lt;/TD&gt;&lt;TD align="left"&gt;&lt;input type="text" name="subject" id="subject" /&gt;&lt;/TD&gt;&lt;/TR&gt; 
 &lt;TR&gt;&lt;TD align="right"&gt; &lt;b&gt;Message :&lt;/b&gt;&lt;/TD&gt;&lt;TD align="left"&gt;&lt;textarea name='message' id='message'&gt;&lt;/textarea&gt;&lt;/TD&gt;&lt;/TR&gt;
 &lt;TR&gt;&lt;TD colspan="2" align="center"&gt;&lt;label for="agree"&gt;&lt;input type="checkbox" name="agree" id="agree" checked="checked"&gt; I agree to terms and Conditions&lt;/label&gt; &lt;/TD&gt;&lt;/TR&gt; 
 &lt;TR&gt;&lt;TD colspan="2" align="center"&gt;&lt;input type="submit" value="Submit" class="submit" /&gt; &lt;/TD&gt;&lt;/TR&gt;
&lt;/TABLE&gt;
&lt;/form&gt;
</code></pre>

<p>The code is not working for name field alone. It works fine if I comment the code of name filed. what could be wrong?? In my other form, textarea field alone is not working. In this form message field i.e textarea validation is working.</p>

<p>This is what happens. When I submit form, If name filed is empty, it shows alert and directly going to target page. If I comment the code for name validation, rest of the code works fine by alerting relevent errors.</p>
