How to use Twitter Bootstrap popovers for jQuery validation notifications?

后端 未结 16 1699
无人共我
无人共我 2020-11-30 16:49

I can make popovers appear using bootstrap easily enough, and I can also do validations using the standard jQuery validation plugin or the jQuery validation engine, but I ca

16条回答
  •  甜味超标
    2020-11-30 17:19

    Please take a look at the following:
    - https://gist.github.com/3030983
    I think it's the simplest of all.

    EDIT

    Code from link:

    $('form').validate({
        rules: {
            numero: {
                required: true
            },
            descricao: {
                minlength: 3,
                email: true,
                required: true
            }
        },
    
        showErrors: function (errorMap, errorList) {
    
            $.each(this.successList, function (index, value) {
                $(value).popover('hide');
            });
    
    
            $.each(errorList, function (index, value) {
    
                console.log(value.message);
    
                var _popover = $(value.element).popover({
                    trigger: 'manual',
                    placement: 'top',
                    content: value.message,
                    template: '

    ' }); _popover.data('popover').options.content = value.message; $(value.element).popover('show'); }); } });

提交回复
热议问题