-1

我正在使用 FormValidation,一个 jQuery 插件来验证我的表单。

如果我有这样的验证设置:

$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

我怎样才能做到这一点?我需要更改或添加以上哪些设置?

4

1 回答 1

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'
          }
        }
      }
}

设置:实时表格

我已经创建了一个答案。谢谢@CBroe

于 2017-01-17T11:21:13.843 回答