title: Javascript validation is not working in html registration form
body: <p>I am using php mysql for user registration. I have added javascript validation to check if any field is blank or not. But the form validation is not working. the form is </p>
  
  <pre><code>&lt;?php
  include("header.php");
  include ("includes/mainmenu.php");
  ?&gt;
  
  
  &lt;!--Javasript Validation File Import --&gt;
  &lt;script type="text/javascript" src="js/validation.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="js/formreg.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" language="JavaScript"&gt;
  
  function HidePart(d) { document.getElementById(d).style.display = "none";  }
  function ShowPart(d) { document.getElementById(d).style.display = "block"; }
  function CheckboxChecked(b,d)
  {
     if(b) { ShowPart(d); }
     else  { HidePart(d); }
  }
  &lt;/script&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;!--&lt;link rel="stylesheet" type="text/css" href="styles/styles.css" /&gt;--&gt;
  &lt;link href="styles/form.css" rel="stylesheet" type="text/css"&gt;
  &lt;link href="styles/structure.css" rel="stylesheet"&gt;
  &lt;link href="styles/bootstrap.css" rel="stylesheet"&gt;
  
  &lt;/head&gt;
  
  &lt;body onLoad="document.registration.userid.focus();"&gt;
  &lt;br&gt;
  &lt;div id="container" class="ltr"&gt;
      &lt;header id="header" class="info"&gt;
  &lt;h2&gt;User Registration&lt;/h2&gt;
  &lt;/header&gt;
      &lt;form action="insert.php" method="post" name="regForm" onSubmit="return valide()"&gt;
  
  
              &lt;ul&gt;
  
              &lt;li id="foli0" class="notranslate"&gt;
              &lt;label class="desc" id="title0" for="Field0"&gt;Name&lt;/label&gt;
              &lt;span&gt;&lt;input id="fname" type="text" name="fname" class="field text1 fn" size="50"/&gt;&lt;/span&gt;&lt;span&gt;Please Enter Your full Name&lt;/span&gt;
              &lt;/li&gt;
  
              &lt;li id="foli0" class="notranslate"&gt;
              &lt;label class="desc" id="title0" for="Field0"&gt;Username&lt;/label&gt;
              &lt;span&gt;&lt;input id="Field0" type="text" name="usernamename" class="field text1 fn"  size="50" /&gt;&lt;/span&gt;
              &lt;/li&gt;
  
              &lt;li id="foli0" class="notranslate"&gt;
              &lt;label class="desc" id="title0" for="group"&gt;Educational Background&lt;/label&gt;&lt;/td&gt;
              &lt;span&gt;&lt;select id="Field0" class="field text1 fn" name="background" size="0"&gt;
                  &lt;option selected="0" value=""&gt;select your Background&lt;/option&gt;
                  &lt;option value="Science"&gt;Science&lt;/option&gt;
                  &lt;option value="Humanities"&gt;Humanities&lt;/option&gt;
                  &lt;option value="Commerce"&gt;Commerce&lt;/option&gt;
                  &lt;/select&gt;&lt;/span&gt;&lt;span&gt;Enter your HSC Background&lt;/span&gt;
              &lt;/li&gt;
  
              &lt;li id="foli0" class="notranslate"&gt;
              &lt;label class="desc" id="title0" for="Field0"&gt;Date of Birth&lt;/label&gt;
              &lt;span&gt;&lt;input id="Field0"  type="date" name="birth" class="field text1 fn"  size="50"/&gt;&lt;/span&gt;&lt;span&gt;Enter your date of Birth&lt;/span&gt;
              &lt;/li&gt;
  
              &lt;li id="foli0" class="notranslate"&gt;
              &lt;label class="desc" id="title0" for="Field0"&gt;Password&lt;/label&gt;
              &lt;span&gt;&lt;input id="Field0"  type="password" name="password" class="field text1 fn" size="50" /&gt;&lt;/span&gt;&lt;span&gt;Enter your password&lt;/span&gt;
              &lt;/li&gt;
  
              &lt;li id="foli0" class="notranslate"&gt;
              &lt;label class="desc" id="title0" for="Field0"&gt;Password&lt;/label&gt;
              &lt;span&gt;&lt;input id="Field0"  type="password" name="conpassword"  class="field text1 fn" size="50" /&gt;&lt;/span&gt;&lt;span&gt;Enter your password again&lt;/span&gt;
              &lt;/li&gt;
  
              &lt;li id="foli0" class="notranslate"&gt;
              &lt;label class="desc" id="title0" for="Field0"&gt;Email&lt;/label&gt;
              &lt;span&gt;&lt;input id="Field0"  type="text" name="email" class="field text1 fn" size="50" /&gt;&lt;/span&gt;&lt;span&gt;Enter a valid email address&lt;/span&gt;
              &lt;/li&gt;
              &lt;li class="buttons "&gt;
              &lt;div&gt;
  
                      &lt;input id="submit" name="submit" class="btn" type="submit" value="Complete Registration"/&gt;&lt;/div&gt;
              &lt;/li&gt;
  
              &lt;/ul&gt;
          &lt;/form&gt;
  
  
  
              &lt;/div&gt;
  
  
  &lt;?php
  include("includes/footer.php");
  ?&gt;
  </code></pre>
  
  <p>and the validation javascript code is</p>
  
  <pre><code>function valide()
  {
  var fname=document.forms["regForm"]["fname"].value;
  var username=document.forms["regForm"]["username"].value;
  var subject = document.forms["regForm"]["background"].value;
  var password=document.forms["regForm"]["password"].value;
  var conpassword=document.forms["regForm"]["conpassword"].value;
  var email=document.forms["regForm"]["email"].value;
  var atpos=email.indexOf("@");
  var dotpos=email.lastIndexOf(".");
  
  
  if (fname==null || fname=="" || fname.length&lt;7)
    {
    alert("Please provide Your full name");
    return false;
    }
  
  else if (username==null || username=="")
    {
        if(username.length&lt;6)
          {
              alert("Username must contains atleast 6 charecters");
          }
          else
    alert("Please provide a username");
    return false;
    }
   else if(subject==null || subject == "")
      {
          alert("Enter Background");
          return false;
          } 
   else if (password==null || password=="")
    {
        if(password.length&lt;8)
          {
              alert("Password must contain atleast 8 charecters");
              }
              else
    alert("Please insert your password");
    return false;
    }
     else if (conpassword != password)
    {
    alert("Confirm password doesn't match");
    return false;
    }
  
  else if (email==null || email=="")
    {
    alert("Email must be filled out.");
    return false;
    }
  
  else if (atpos &lt;1 || dotpos &lt;atpos+2 || dotpos + 2 &gt;= email.length)
    {
    alert("Not a valid e-mail address");
    return false;
    }
  }
  </code></pre>
  
  <p>Please help me.</p>