title: Validate before going to next page
body: <p>Peeps,</p>
  
  <p>I see this question has been asked but they either don't have validation function right or there are some syntax errors.</p>
  
  <p>Here is my code; it is supposed to check fields are not blank then if they are not blank it passes them to the next page.</p>
  
  <p>What happens with my codes is that it does check the validation but right after the Alert pop-up it goes to the next page. My intention is to not go to the next page unless all fields are filled.</p>
  
  <p>Any hints would be greatly appreciated.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;      
          &lt;script type="text/javascript"&gt;
  
              function RegValidation() {              
                  var txtURL, 
                   if (!txtURL) {
                      alert("URL is mandatory!");
                      return false;
                    }
                   return true;
              }               
          &lt;/script&gt;
  &lt;/head&gt; 
  &lt;body&gt;  
          &lt;form name="RegisterForm" action="RegConfirm.php" method="post"&gt;            
  
                  &lt;p&gt;&lt;input type="text" name="txtURL"&gt;&lt;/p&gt;
  
                  &lt;p&gt;&lt;input type="submit" value="Register" onclick="Register()"&gt;&lt;/p&gt;                                      
          &lt;/form&gt;
  
  &lt;/body&gt;
  
  &lt;script type="text/javascript"&gt; 
  
      function Register() {
  
      if (!RegValidation()) return;        
       }
  
  &lt;/script&gt;
  </code></pre>
  
  <p></p>