Note that there are some explanatory texts on larger screens.

plurals
  1. POvalidating a form then displaying the other hidden form using jquery
    primarykey
    data
    text
    <p>i'm having a bit of a problem with my jquery code..i have two forms in my page..one displays when the user loads the page and the other is hidden(set to style="display:none;"). I want to fill out all the details in the first form and on clicking next, display the hidden form..problem is, the hidden form gets displayed on clicking the 'next' button even when the first form has no input..so i'm guessing i'm doing something wrong with the jquery validation code(i'm using the jQuery Validation plugin)..any help would be appreciated.thanks in advance</p> <p>Here's how my code looks like: The DETAILS</p> <pre><code>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"&gt; &lt;/script&gt; &lt;script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.8/jquery.validate.min.js"&gt;&lt;/script&gt; &lt;body&gt; &lt;div class="item item1"&gt; &lt;form action="index.html" method="get" id = "form1"&gt; &lt;h1&gt;The DETAILS&lt;/h1&gt; &lt;p align="justify"&gt;Try our FREE landlord cost calculator and&lt;br&gt; discover the real cost of letting your property. &lt;br&gt; &lt;input name="name" type="text" placeholder="your name"class="required" /&gt; &lt;br&gt; &lt;input name="email" type="text" placeholder="your email" class="required" /&gt; &lt;br&gt; &lt;input name="phone" id="phone" type="text" placeholder="your phone no" class="required" /&gt; &lt;br&gt; &lt;input name="postcode" id="postcode" type="text" placeholder="postcode of property to let" class="required" /&gt; &lt;br&gt; &lt;select name="bedrooms" id="bedrooms" placeholder="bedrooms" class="required" &gt; &lt;option value="1"&gt;1&lt;/option&gt; &lt;option value="2" &gt;2&lt;/option&gt; &lt;option value='' disabled selected="selected"&gt;Please Choose&lt;/option&gt; &lt;/select&gt; &lt;br&gt; &lt;input name="hearAbout" type="text" placeholder="where did your hear about us?" class="required" /&gt; &lt;br&gt; &lt;button class="submit button1 " id = "next" name="submit" type="submit" value="next"&gt;&lt;span class="next "&gt;&gt;&lt;/span&gt;next&lt;/button&gt; &lt;/p&gt; &lt;/form&gt; &lt;/div&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ $("#form1").validate(); }); &lt;/script&gt; &lt;script&gt; $("#form1").submit(function() { /* AJAX calls and insertion into #form2 */ $("#form2").show(); return false; }); &lt;/script&gt; &lt;div class="item item2"&gt; &lt;form action="calculation.php" method="post" id = "form2"style="display:none;"&gt; &lt;h1&gt;The Income&lt;/h1&gt; &lt;label&gt; Estimated monthly rent:&amp;pound; &lt;/label&gt; &lt;input name="rent" id="rent" type="text" /&gt;&lt;hr&gt; THE COSTS STEP 3 &lt;hr&gt; Agents Commission: &lt;select name="commission" id="commission"&gt; &lt;option value="10%"&gt;10%&lt;/option&gt; &lt;option value="12%" selected="selected"&gt;12%&lt;/option&gt; &lt;/select&gt; &lt;hr&gt; Estimated Setup Fees:&amp;pound; &lt;input id="fees" name="fees" type="text" /&gt;&lt;hr&gt; How many weeks in the year do you estimate &lt;br&gt;that your property will&lt;br&gt; be vacant/empty?&lt;input name="weeks" type="text" /&gt;&lt;hr&gt; &lt;button class="submit button2" name="submit" type="submit" value="calculate"&gt;&lt;span class="next"&gt;&gt;&lt;/span&gt;calculate&lt;/button&gt; &lt;/form&gt; &lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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