user695663
user695663

Reputation: 12366

Jquery Validate Plugin to validate seperate sections with controls

I have different div sections with some controls in each. I have a button to navigate from one section to the other. all of the divs are in one single form "form1". Here is the layout:

form id="form1"
div id="section1"
input type="text" id="1">
input type="text" id="2">
input type="text" id="3">
input type="button">
/div>
div id="section2">
input 4>
input 5>
input 6>
button to next section>
/div>

/form>

I am trying to achieve validating controls in each div when the respective button is clicked. clicking button in section 1 should validate all controls 1-3 and then navigate to other section. Let me know how to achieve this.

Thanks.

Upvotes: 0

Views: 937

Answers (2)

dkl
dkl

Reputation: 3942

There is official demo at jQuery Validate website: http://jquery.bassistance.de/validate/demo/multipart/

Upvotes: 0

Chad
Chad

Reputation: 19619

You can easily accomplish something like this using jQuery:

$(document).ready(function() {
   //bind click event to section 1's submit button
   $('div#section1').children(':button').click(function() {
      //validate section 1 controls
   });

   //do the same for section 2
   $('div#section2').children(':button').click(function() {
      //validate section 2 controls
   });
});

Upvotes: 1

Related Questions