0

I have a multistep form which is within a single form. I want to validate every single step, for eg. if i'm validating content inside div with id 1 then only that div validation should work but current scenario is the validation is not working if i have single form for all the steps and I don't want multiple forms to be validated. Is there any way to fulfill the above requirement?

<div>
  <form name="" id="">
    <div id="1"></div>
    <div id="2"></div>
    <div id="3"></div>
    <div id="4"></div>
  </form>
</div>
jQuery('form#addform select').each(function() {
  jQuery(this).rules('add', {
    required_select: true
  });
});

jQuery.validator.addMethod('required_select', function(value, element) {
  return value > 0;
}, 'Please choose a option');

jQuery("form#addform").validate({
  submitHandler: function(form) {
    // ...
  }
});
3
  • You'll need to clarify your question. What does/doesn't work in your current code? Commented Jan 15, 2020 at 11:10
  • 3
    There's an example multi step form on the jQuery validate website: jqueryvalidation.org/files/demo/multipart Commented Jan 15, 2020 at 11:21
  • You can also add customised solution to achive this rather than depending on validator js file Commented Jan 15, 2020 at 11:25

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.