简体   繁体   English

文本框弹出窗口上的Twitter Bootstrap验证消息

[英]Twitter Bootstrap Validation message on textbox popover

Twitter Bootstrap Validation message on textbox popover 文本框弹出窗口上的Twitter Bootstrap验证消息

Hi All, 大家好,

I have tried a validation using bootstrap validation. 我已经尝试使用引导验证进行验证。 this is my code 这是我的代码

HTML HTML

  <form role="form" id="book-form" class="land-form">
                                <div class="form-group">
                                    <input type="text" name="contactname" class="form-control" id="t1" placeholder="Name">
                                </div>
                                <div class="form-group">
                                    <input type="text" name="contactemail" class="form-control" id="t2" placeholder="Email">
                                </div>
                                <div class="form-group">
                                    <input type="text" name="contactphonenumber" class="form-control" id="t3" placeholder="Phone Number">
                                </div>
                                <div class="form-inline">
                                    <div class="form-group">
                                        <div class='input-group date' id='datetimepicker1'>
                                            <input type='text' name="contactdate" class="form-control date" id="t4" placeholder="Date" />
                                            <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
                                            </span>
                                        </div>
                                    </div>

                                    <div class="form-group" style="display: inline-block; vertical-align: top;">
                                        <select class="form-control col-md-3" name="guests">
                                            <option>--No of Guests--</option>
                                        </select>

                                    </div>
                                </div>
                                <div class="form-group text-right">
                                    <button type="submit" class="btn book-btn">Book Your Ticket</button>
                                </div>
                            </form>

JS JS

$('#book-form').bootstrapValidator({
        //        live: 'disabled',       
        message: 'This value is not valid',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            contactname: {
                validators: {
                    notEmpty: {
                        message: '*Required Field'
                    }
                }
            },
            contactphonenumber: {
                validators: {
                    notEmpty: {
                        message: '*Required Field'
                    }
                }
            },
            contactdate: {
                validators: {
                    date: {
                        format: 'MM/DD/YYYY',
                        message: 'The value is not a valid date'
                    }
                }
            },
            email: {
                validators: {
                    notEmpty: {
                        message: '*Required Field'
                    },
                    emailAddress: {
                        message: 'The input is not a<br> valid email address'
                    }
                }
            }

        }

    });

Now the error message display look like 现在错误消息显示如下

在此处输入图片说明

The messages are showing bottom of the text box. 消息显示在文本框的底部。


I want to Show this message in **popover , Look like the below image** 我想在** popover中显示此消息,如下图所示**

在此处输入图片说明

How can i do this with bootstrap validator ?? 我该如何使用Bootstrap验证程序呢

Note 注意

I want this using by bootstrap validator , NOT Jquery Validator 我想通过引导验证器而不是Jquery验证器使用

Also i have tried this way : http://bootstrapvalidator.com/settings/#form-container 我也尝试过这种方式: http : //bootstrapvalidator.com/settings/#form-container

But not working ! 但是不行!

The problem is in bootstrapValidator, described on github in issue #754 . 问题出在bootstrapValidator中,该问题在GitHub上的问题#754中进行了描述。 You either need to use a newer version of the validator, or patch in that bug fix to your version, essentially adding container:'body' to the calls to Bootstrap tooltip/popover. 您要么需要使用验证器的更新版本,要么要在该版本的错误修复程序中打补丁,从而在对Bootstrap工具提示/弹出窗口的调用中添加container:'body'

Otherwise, it's just a matter of adding this code to your bootstrapValidator call: 否则,只需将以下代码添加到bootstrapValidator调用中即可:

$('#book-form').bootstrapValidator({
       container: 'popover',
       //rest of your options
});

Working example here: http://jsfiddle.net/f2dqz95y/ (I didn't get as far as getting bootstrap fully working, so it still looks weird... but the popovers do work) 这里的工作示例: http : //jsfiddle.net/f2dqz95y/ (我还没有达到引导程序完全可以工作的程度,所以看起来仍然很奇怪……但是弹出窗口确实可以工作)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM