How to validate wysiwyg editor using bootstrap validation

后端 未结 2 1775
暗喜
暗喜 2021-01-20 15:56

Using

bootstrap3-wysihtml5-bower 2013-11-22 (WYSIWYG Editor)

and

BootstrapValidator v0.5.2

2条回答
  •  猫巷女王i
    2021-01-20 16:33

    Folks, bootstrapValidator has been upgraded to formValidation. If you are using the updated version of formValidation you can do this instead of adding a separate class to hide the text area:

       $('#setpolicyform').formValidation({
                                    framework: 'bootstrap',
                                    excluded: [':disabled'], /* This will do the trick of validating for notEmpty*/
                                    icon : {
                                        valid : '',
                                        invalid : '',
                                        validating : 'glyphicon glyphicon-refresh'
                                    },
                                    fields: {
                                     policyta: {
                                      group: '.lnbrd',
                                      validators: {
                                       notEmpty: {
                                       message: 'Textarea cannot be empty'
                                       },
                                       stringLength: {
                                        max: 50,
                                       message: 'Maximum 50 Characters Required'
                                   }
                                }
                             }
                          }
            });
    
    $('.textarea').wysihtml5({
            events: {
                change: function () {
                    $('#setpolicyform').formValidation('revalidateField', 'policyta');
            }
        }
    });
    

    Thanks

提交回复
热议问题