I broke my form in the div and using the "Next" buttons to shop and hide these sections. I also use the jQuery validation plugin to do all the validation for me.
I need to know how to check a section by section. So here I am
- personal information
- Address Information
- Project Information
- Terms and Conditions
2,3 and 4 are hidden by default to make the form less complicated.
Clicking on the next button of personal information will hide this div and show the address data, etc.
On the very last screen, there is a submit form button that would then check the entire form, but I need to check each section before the user goes.
Here is what I thought was supposed to work:
CSS
.project-address {display:none;}
HTML
<form class="wpcf7"> <div class="project-details"> <h2>Project details</h2> <label>Project name: </label><input type="text" class="reg-project-name" size="40" value="" name="projectName"> <div class="back-next"><span class="reg-next-button">Next</span></div> </div> <div class="project-address"> <h2>Project address</h2> <label>Project address:</label><input type="text" class="reg-project-address" size="40" value="" name="projectAddress"> <div class="back-next"><span class="reg-next-button">Next</span></div> </div> </form>
JQuery
//clicking the next button hides this section and shows the next section jQuery('.project-details .reg-next-button').click(function() { // jQuery(".project-details").slideUp(); // jQuery('.project-address').slideDown(); jQuery('.reg-project-name').validate({ debug: true, rules: { projectName: "required" }, messages: { projectName: "Please give your project a name", } }); });
EDIT: tried to check one element as follows.
jQuery('.project-details .reg-next-button').click(function() { // jQuery(".project-details").slideUp(); // jQuery('.project-funding').slideDown(); var validator = jQuery( ".wpcf7-form" ).validate(); validator.element( ".reg-project-name" ); });
EDIT: If I click the "Next" button, I need the form elements to be checked in this div before moving around which does not happen. those. form elements are not validated.
Any thoughts? Many thanks.