2016-08-03 3 views
1

enter image description here I은 ​​필수가 아닌 "txtPhone"입력 필터를 가지고 있지만 전화 번호를 받아 들일 수 있도록 :필드가 비어있는 경우 글리프콘을 표시하지 않는 방법은 무엇입니까?

<label class="control-label">Phone</label> 
<input type="text" id="txtPhone" class="form-control intonly" maxlength="12" placeholder="Phone" name="Phone"> 

부트 스트랩 검증

Phone: { 
         validators: { 
          regexp: { 
           regexp: /^((091|\+91)?|\((091|\+91)?\)|(91)?|\(91\)|0)? ?[7-9][0-9]{9}$/, 
           message: 'The Indian Phone No must contain 10 digits' 
          }, 

         } 
        }, 

하지만 난이 제출 '버튼을 클릭했을 때의 표시 틱 텍스트 상자. TRUE ':

+0

'요구를 찾을? –

+0

이지만 필수는 아닙니다. – Wenson

+0

그래서 문제가 무엇입니까? 필드가 비어 있으면 유효합니다 ... –

답변

1

롱 어려움을 겪고 JesusGrace 후 내가 대답

Bootstrap Validation 

    Phone: { 
        enabled: false, 
        validators: { 
         regexp: { 
          regexp: /^((091|\+91)?|\((091|\+91)?\)|(91)?|\(91\)|0)? ?[7-9][0-9]{9}$/, 
          message: 'The Indian Phone No must contain 10 digits' 
         }, 

        } 
       }, 


     .on('keyup', '[name="Phone"]', function() { 
       var isEmpty = $(this).val() == ''; 
       $('#form1') 
         .formValidation('enableFieldValidators', 'Phone', !isEmpty); 
       // Revalidate the field when user start typing in the Phone field 
       if ($(this).val().length == 1) { 
        $('#form1').formValidation('validateField', 'Phone') 
       } 
      }) 
관련 문제