2017-01-17 49 views
-1

我正在使用 FormValidation,一個jQuery插件來驗證我的表單。如何在爲jQuery插件輸入值時禁用驗證 - formvalidation?

如果我有一個驗證的設置是這樣的:

$form.formValidation({ 
    framework: 'bootstrap', 
    excluded: ':disabled', 
    message: 'This value is not valid', 
    row: { 
     selector: 'div' 
    }, 
    fields: { 
     'name': { 
     validators: { 
      notEmpty: { 
      message: 'Please enter your name' 
      } 
     } 
     } 
} 

在每一個輸入到我的輸入字段name,驗證觸發。我想驗證觸發只有當我點擊submit按鈕(which I have already done in my code),但I am failing to disable the validation when entering a value into a input field

我該怎麼做?以上需要更改或添加哪些設置?

+0

http://formvalidation.io/settings/#form-live – CBroe

回答

0

答案是增加一個live屬性並將其設置爲disabled這樣的:

$form.formValidation({ 
    framework: 'bootstrap', 
    excluded: ':disabled', 
    live: 'disabled', 
    message: 'This value is not valid', 
    row: { 
     selector: 'div' 
    }, 
    fields: { 
     'name': { 
     validators: { 
      notEmpty: { 
      message: 'Please enter your name' 
      } 
     } 
     } 
} 

Settings: Form live

我已經創建了一個答案。謝謝@CBroe

相關問題