无法使用Bootstrap验证程序正确验证URL字段

时间:2018-06-05 09:20:46

标签: jquery bootstrap-4 bootstrapvalidator

我在使用bootstrap验证程序验证URL字段时遇到问题。我在下面提供我的代码。

<form class="form-horizontal" role="form"  id="instmanageformid" name="instmanageformid">
   <div class="form-group">
       <label for="" class="col-sm-2 control-label">Website</label>
       <div class="col-sm-10">
       <input type="text" class="form-control tooltips" id="txtWebaddress" name="txtWebaddress" placeholder="Web site Address" title="Web site Address">
        </div>
    </div>
</form>

manage.js:

$('#instmanageformid').bootstrapValidator({
        message: 'This value is not valid',
        feedbackIcons: 
        {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        submitButtons: 'button[type="submit"]',
        submitHandler: function(validator, form, submitButton){
        },
        fields:{
           txtWebaddress:{
                validators: {
                    notEmpty: {
                        message: 'Website Address is required and cannot be empty'
                    },
                    uri: {
                        message: 'The input is not a valid URL.Dont Forget to Use http:// or https://'
                    }
                }
            }
        }
})

我面临的问题是,如果我在网站字段中使用www.abcd.com,我收到的错误为The input is not a valid URL. Don't Forget to use http:// or https://,我不想要。如果这些网址有www,我希望它能正常工作。

0 个答案:

没有答案