Q:

Hiding and showing Divs with form validation

Upon submit I am trying to have "quiz" hide and have "thanks" be shown. All was working correct until I added a JavaScript form validation code, and now it just reloads the first div "welcome" I thought adding "#thanks" to the action upon submit would solve the issue, but it did not. Then trying to add an "if true" statement to my form validation ended up breaking the form validation. I am using  jquery.validate to validate my form as suggested. With the current code it skips the validation and just shows "thanks" If anyone has any suggestions it would be greatly appreciated. 
    <div id="quiz">
        <form class="cmxform" id="commentForm" method="get" action="" onSubmit="showHide(); return false;">
             <label for="cname">Name</label>
             <input id="cname" name="name" size="20" class="required" minlength="2" />
           </p>
           <p>
             <label for="ccompany">Company Title</label>
             <input id="ccompany" name="company" size="20"  class="required company" minlength="2" />
           </p>
           <p>
             <label for="cnumber">Phone Number</label>
             <input id="cnumber" name="number" size="20"  class="required number" />
           </p>
           <p>
             <label for="cemail">Email</label>
             <input id="cemail" name="email" size="20"  class="required email" />
         <p></p>   
    <input class="submit" type="submit" value="Submit" align="center"/>
    </form>
    </div> 

  <div id="thanks"><h2>Thank you.</h2>
You will receive an email momentarily
</div>

   <script>
$("#begin").click(function(){
    $("#quiz").show();
    $("#welcome").hide();    
});
 function showHide(){
    $("#thanks").show();
    $("#quiz").hide();    
};

</script>

A:

All I can say is that you are doing it wrong.... While the form validation that you are doing can work there are a lot of good form validation jquery plugins that would both simplify your life and add a much richer user experience.  jquery.validate is probably the most widely used library and would be well worth using.

