2009-06-23 5 views
7

다단계 양식의 유효성을 검사해야합니다. 이 일을위한 괜찮은 플러그인이 있습니까? 예를 들어jquery 다중 단계 양식 유효성 확인

:

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

#step1는 필드 세트이다. 당신이 기본적인 아이디어는 임시 형태로 포장하는 4 개 라인

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

에 빠른 해킹 괜찮 있다면

답변

1

나는 단지이 제안하고 있습니다. 유효성 검사. 풀다. 반복.

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

어떻게 이런 일에 대해 :

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