Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如果字段为空,如何不显示glyphicon ok?_Jquery_Asp.net_Twitter Bootstrap_Jquery Ajaxq - Fatal编程技术网

Jquery 如果字段为空,如何不显示glyphicon ok?

Jquery 如果字段为空,如何不显示glyphicon ok?,jquery,asp.net,twitter-bootstrap,jquery-ajaxq,Jquery,Asp.net,Twitter Bootstrap,Jquery Ajaxq,我有一个“txtPhone”输入过滤器,它不是强制性的,但只能接受电话号码,因此: <label class="control-label">Phone</label> <input type="text" id="txtPhone" class="form-control intonly" maxlength="12" placeholder="Phone" name="Phone"> 但当我点击文本框中显示的提交按钮时,勾选。经过长时间的努力,我找到了

我有一个“txtPhone”输入过滤器,它不是强制性的,但只能接受电话号码,因此:

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

但当我点击文本框中显示的提交按钮时,勾选。

经过长时间的努力,我找到了答案

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

但这不是强制性的,那有什么问题呢?如果字段为空,则该字段有效…如果字段为空,则无需单击图标ok。这是我的要求。
  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')
                }
            })