首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >bootstrap typeahead的BootstrapValidator

bootstrap typeahead的BootstrapValidator
EN

Stack Overflow用户
提问于 2014-09-04 21:39:18
回答 1查看 1.1K关注 0票数 0

我想知道BootstrapValidator http://bootstrapvalidator.com/是否有typeahead的验证。

我有一个表单,其中我使用验证器验证我的字段。

但是,每当我开始在输入字段中键入内容时,验证器就会验证它的true。我想要的东西,它必须验证后,只有在typeahead选择,而不是通过在输入字段中写入。

代码语言:javascript
复制
$(document).ready(function() {
        var options = {};
        options.common = {
            minChar: 1
        };
        options.ui = {
            showVerdictsInsideProgressBar : true,
            viewports : {
                progress : ".pwstrength_viewport_progress"
            }
        };
        .......
        $('#user_country').on('input', function() {
            $(this).parent().find('.small').hide();
        });
        $('#user_reg_form').bootstrapValidator({
            excluded: ':disabled',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
               ........
                country: {
                    validators: {
                        notEmpty: {
                            message: 'city is required'
                        }
                    }
                },
            }
        })

我的typeahead看起来像这样

代码语言:javascript
复制
 $(ele).typeahead({
   select:function(){
        // here i do the select.....
   }
 });
EN

回答 1

Stack Overflow用户

发布于 2014-09-17 21:59:55

我在使用日期选择器时遇到了类似的问题-你可以尝试手动绑定验证-例如:

代码语言:javascript
复制
$('#userCountry').on('blur', function(e) {
    $('#user_reg_form').bootstrapValidator('revalidateField', 'userCountry');
});

您的typeahead控件是否将它们限制为列表中的一个选项?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25667016

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档