Note that there are some explanatory texts on larger screens.

plurals
  1. POHiding and showing Divs with form validation
    primarykey
    data
    text
    <p>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. </p> <pre><code> &lt;div id="quiz"&gt; &lt;form class="cmxform" id="commentForm" method="get" action="" onSubmit="showHide(); return false;"&gt; &lt;label for="cname"&gt;Name&lt;/label&gt; &lt;input id="cname" name="name" size="20" class="required" minlength="2" /&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="ccompany"&gt;Company Title&lt;/label&gt; &lt;input id="ccompany" name="company" size="20" class="required company" minlength="2" /&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="cnumber"&gt;Phone Number&lt;/label&gt; &lt;input id="cnumber" name="number" size="20" class="required number" /&gt; &lt;/p&gt; &lt;p&gt; &lt;label for="cemail"&gt;Email&lt;/label&gt; &lt;input id="cemail" name="email" size="20" class="required email" /&gt; &lt;p&gt;&lt;/p&gt; &lt;input class="submit" type="submit" value="Submit" align="center"/&gt; &lt;/form&gt; &lt;/div&gt; &lt;div id="thanks"&gt;&lt;h2&gt;Thank you.&lt;/h2&gt; You will receive an email momentarily &lt;/div&gt; &lt;script&gt; $("#begin").click(function(){ $("#quiz").show(); $("#welcome").hide(); }); function showHide(){ $("#thanks").show(); $("#quiz").hide(); }; &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload