2011-12-09 16 views
1

現在、jQuery検証プラグインは、選択したタブのみを検証します。だから、すべてのタブが、私はjQueryフォーム送信時にすべてのタブを検証する

$("form").validate({ 
.... 
.... 
ignore:"ui-tabs-hide" 
}); 

属性無視導入しかし、これを与えた後、それも隠しフィールドを検証し、検証することにします。各タブの隠しフィールドだけを無視して、すべてのタブのフィールドを検証する方法はありますか?

HTML

<div id="tabs"> 
<%@include file="inc/tabsList.jsp" %> <!--has <a> link for each div --> 

<div id="fragment-1"><%@include file="inc/tradeDetails.jsp" %></div> 
<div id="fragment-2"><%@include file="inc/beneficiaryDetails.jsp" %></div> 
<div id="fragment-3"><%@include file="inc/referenceDetails.jsp" %></div> 
<div id="fragment-4"><%@include file="inc/summary.jsp"%></div> 

<div class="clear"></div> 

</div> 

はJavaScript

$(function() { 
var hiddenChevron; 
var $tabs = $('#tabs').tabs(); 

$("#fWdErrors_940").hide(); 

$("#singleSpotForm").validate({ 
     rules: { 
      'singleSpotRequestVO.entity.entityName' : "required", 
      'singleSpotRequestVO.subEntity.entityName' : "required",     
      'singleSpotRequestVO.transactionType' : "required", 
      'singleSpotRequestVO.tradeCurrencyId' : "required" 
     }, 
     errorContainer: 'fWdErrors_940', 
     errorClass: "errorMsgItemText", 
     errorPlacement: function(error, element) {    
      error.appendTo(element.parent("td").last()); 
     }, 
     invalidHandler: function(form, validator) { 
      var errors = validator.numberOfInvalids(); 
      if(errors){ 
       var message = validator.numberOfInvalids() == 1 ? 
         validator.numberOfInvalids() + " error " : 
         validator.numberOfInvalids() + " errors "; 
       $(".failureErrCount").html(message); 
       $("#fWdErrors_940").show().focus(); 
      }else{ 
       $("#fWdErrors_940").hide(); 
      } 

     }, 
     onkeyup : false, 
     ignore: "ui-tabs-hide" 

}); 
}) 
+0

限り、すべての入力要素が一つの形態であるように、検証プラグインはまだそれらを確認する必要があります。 HTMLのサンプルを投稿できますか? –

答えて

3

優秀で...解決策を組み合わせた:

$("form").validate({ 
.... 
.... 
ignore:"ui-tabs-hide" 
}); 

もっと...

$("div[id^=fragment-]").bind("click", function() { 
    $("div[id^=fragment-]").children("input, select, textarea").prop("disabled", true); 
    $(this).children("input, select, textarea").prop("disabled", false); 
}); 
0

あなたは他のコントロールが無効にする必要があります。

はこれを試してみてください:

$("div[id^=fragment-]").bind("click", function() { 
    $("div[id^=fragment-]").children("input, select, textarea").prop("disabled", true); 
    $(this).children("input, select, textarea").prop("disabled", false); 
}); 

これが有効になって現在のタブのコントロールを維持し、他のタブが無効に制御し、したがって、バリデータがタブのみで、現在の要素を検証します。

+0

あなたの返事をありがとう、私は別の方法の周りにしたい。バリデーターは、すべてのタブで利用可能な要素を検証し、隠された要素だけを残します。 – Prithivi

+0

'jquery.validate.js'ではまだ利用できません。開発者に機能要求を検討しようとするかもしれません。 –

+0

機能リクエストの開始場所を教えてください。 – Prithivi

関連する問題