【问题标题】:bootstrapValidator disable error messagebootstrapValidator 禁用错误信息
【发布时间】:2014-07-21 10:33:37
【问题描述】:

是否可以在 bootstrapValidator 中禁用错误​​消息?我在 bootstrapValidator 设置中进行了搜索,但没有这样的选项。我希望根据 bootstrapValidator 的类显示和隐藏我的自定义消息。如何禁用默认错误消息的显示?

【问题讨论】:

    标签: twitter-bootstrap message validation


    【解决方案1】:

    不确定您为什么要这样做,因为您已经可以使用 fields 选项在 bootstrapValidator 中指定自定义消息。以下是为fullNameemail 字段设置自定义消息的示例:

     fields: {
         fullName: {
             validators: {
                 notEmpty: {
                     message: 'The full name is required and cannot be empty'
                 }
             }
         },
         email: {
             validators: {
                 notEmpty: {
                     message: 'The email address is required and cannot be empty'
                 },
                 emailAddress: {
                     message: 'The email address is not valid'
                 }
             }
         },
    

    如果您真的想隐藏所有消息,可以使用container 选项:

     container: '#messages',
    

    然后您可以在 HTML 中隐藏该容器:

     <div id="messages" class="hide"></div>
    

    【讨论】:

    • 如果您只想隐藏一条特定消息怎么办?我一直在尝试删除并向验证器添加字段,但在删除字段后我无法再次显示消息。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-17
    • 1970-01-01
    • 1970-01-01
    • 2012-10-18
    • 1970-01-01
    • 2017-05-12
    相关资源
    最近更新 更多