2009-06-23 17 views
7

मुझे एक बहु-चरण फ़ॉर्म को सत्यापित करने की आवश्यकता है। क्या ऐसा करने के लिए कोई सभ्य प्लगइन्स हैं?jquery बहु चरण फॉर्म सत्यापन

उदाहरण के लिए:

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

#step1 एक क्षेत्र सेट है।

उत्तर

1

मैं केवल यह सुझाव दे रहा हूँ अगर आप 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(); 

मूल विचार एक अस्थायी रूप में लपेट के लिए है में एक त्वरित हैक साथ ठीक हैं। वैधता सुनिश्चित करें। हटाना। दोहराएँ।

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); 
}); 
संबंधित मुद्दे