2009-06-23 5 views
7

Ho bisogno di convalidare un modulo multi-step. Ci sono dei plugin decenti per fare questo?validazione modulo jquery multi step

Ad esempio:

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

#step1 è un insieme di campo.

risposta

1

ho solo suggerire questo se stai bene con un trucco veloce in 4 linee

//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(); 

L'idea di base è quello di avvolgere in una forma temporanea. Convalidare. Rimuovere. Ripetere.

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
0

Che ne dite di qualcosa di simile:

//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); 
});