2014-11-04 3 views
2

부트 스트랩 검사기를 사용하고 있는데 문제는 모든 값이 유효하지만 그렇게 할 수 없으면 제출 버튼을 사용 가능하게하려는 것입니다.부트 스트랩 검사기에서 제출 버튼을 활성화하십시오.

$(document).ready(function() { 
    $('#ans_frm').bootstrapValidator({ 
     feedbackIcons: { 
      valid: 'glyphicon glyphicon-ok', 
      invalid: 'glyphicon glyphicon-remove', 
      validating: 'glyphicon glyphicon-refresh' 
     }, 
     submitButtons: 'button[type="submit"]', 
     fields: { 
      ans: { 
       group: '.col-md-8', 
       validators: { 

        stringLength: { 
         min: 3, 
         max: 100, 
         message: 'The answer must be more than 2 and less than 100 characters long' 
        }, 
        notEmpty: { 
         message: 'The answer must not be empty' 
        } 
       } 

      } 
     } 
    }).on('status.field.bv', function(e, data) { 

       disableSubmitButtons(false); 
      } 
     }); 
}); 

답변

3

당신은 버튼 .on('error.field.bv')를 입력하고 .on('status.field.bv')에 그것을 다시 활성화, 비활성화해야합니다.

그리고 data.bv.disableSubmitButtons() 방법을 사용해야합니다!

시도해 볼 수 있습니까?

$(document).ready(function() { 
    $('#ans_frm').bootstrapValidator({ 
     feedbackIcons: { 
      valid: 'glyphicon glyphicon-ok', 
      invalid: 'glyphicon glyphicon-remove', 
      validating: 'glyphicon glyphicon-refresh' 
     }, 
     submitButtons: 'button[type="submit"]', 
     fields: { 
      ans: { 
       group: '.col-md-8', 
       validators: { 
        stringLength: { 
         min: 3, 
         max: 100, 
         message: 'The answer must be more than 2 and less than 100 characters long' 
        }, 
        notEmpty: { 
         message: 'The answer must not be empty' 
        } 
       } 
      } 
     } 
    }).on('error.field.bv', function(e, data) { 
      data.bv.disableSubmitButtons(true); // disable submit buttons on errors 
     } 
    }).on('status.field.bv', function(e, data) { 
      data.bv.disableSubmitButtons(false); // enable submit buttons on valid 
     } 
    }); 
}); 
+0

그 다음 페이지에 값을 전송하지 않습니다하지만 값을 잘하지 않을 때 validate.The 버튼도 모든 시간을 사용할 수 있습니다 않습니다. – Umerm

2

사용이

$('#ans_frm').bootstrapValidator({ 
      feedbackIcons: { 
       valid: 'glyphicon glyphicon-ok', 
       invalid: 'glyphicon glyphicon-remove', 
       validating: 'glyphicon glyphicon-refresh' 
      }, 
      live: 'enabled', 
      trigger: null 
     }).on('success.form.bv', function (e) { 
      // Prevent submit form 
      // e.preventDefault(); 
     }) 
     .on('error.form.bv', function() { 

     }); 
관련 문제