2014-09-04 101 views
0

我想知道BootstrapValidator http://bootstrapvalidator.com/是否有typeahead驗證。BootstrapValidator for bootstrap typeahead

我有一個窗體,我在哪裏驗證我的領域使用驗證。其中一個字段是一個inout字段,其中附加了typeahead,所以輸入字段由typeahead選擇填充。

但是,無論何時我開始在輸入字段中鍵入驗證器驗證其真實。我想像它一樣,必須在typeahead選擇之後進行驗證,而不是在輸入字段中寫入。

$(document).ready(function() { 
     var options = {}; 
     options.common = { 
      minChar: 1 
     }; 
     options.ui = { 
      showVerdictsInsideProgressBar : true, 
      viewports : { 
       progress : ".pwstrength_viewport_progress" 
      } 
     }; 
     ....... 
     $('#user_country').on('input', function() { 
      $(this).parent().find('.small').hide(); 
     }); 
     $('#user_reg_form').bootstrapValidator({ 
      excluded: ':disabled', 
      feedbackIcons: { 
       valid: 'glyphicon glyphicon-ok', 
       invalid: 'glyphicon glyphicon-remove', 
       validating: 'glyphicon glyphicon-refresh' 
      }, 
      fields: { 
       ........ 
       country: { 
        validators: { 
         notEmpty: { 
          message: 'city is required' 
         } 
        } 
       }, 
      } 
     }) 

我的預輸入看起來像

$(ele).typeahead({ 
    select:function(){ 
     // here i do the select..... 
    } 
}); 

回答

0

我使用日期選擇器遇到了類似的問題 - 你可以嘗試手動綁定驗證 - 如:

$('#userCountry').on('blur', function(e) { 
    $('#user_reg_form').bootstrapValidator('revalidateField', 'userCountry'); 
}); 

請問您的預輸入控制限制他們到列表中的選項之一?