7

I need to validate a multi-step form. Are there any decent plugins for doing this?

For example:

$(function() {
    $('#MoveStep1').click(function() {
        $("#step1").validate();
    });
});

#step1 is a field set.

Sparky
  • 98,165
  • 25
  • 199
  • 285

2 Answers2

1

I'm only suggesting this if you're okay with a quick hack in 4 lines

//untested but you'll get the gist, you may need a slight variation on this
$("#step1").wrap('<form id="tmp-form"></form>');
$("#tmp-form").validate();
$("#step1").insertBefore("#tmp-form");
$("#tmp-form").remove();

The basic idea is to wrap it in a temporary form. Validate. Remove. Repeat.

Benefits:  
use a validation plugin you already know and is well-tested. 
you don't need to change any existing validation rules

Cons:
possible undesired layout effects depending on you style markup
maybe others? once again, not tested just a quick thought
Keith Bentrup
  • 11,834
  • 7
  • 49
  • 56
0

How about something like this:

//setup validation, don't validate if the control is: ignored, inside an ignored container, or hidden
$("form").validate({ ignore: ".ignore, .ignore *, :hidden" });

$("#MoveStep1").click(function() {
    //assuming each step is in a container with the class Step
    $(".Steps:not(#step1)").addClass(.ignore);
    $("form").valid();
    $(".Steps").removeClass(.ignore);
});
Homer
  • 7,594
  • 14
  • 69
  • 109