bootstrapvalidator gives “Cannot read property 'group' of undefined” on ckeditor field

那年仲夏 提交于 2019-12-08 07:14:44

问题


I'm using ckeditor on a text area and I need to set a custom validation.

Following the example, I set the textbox using the jquery adapter in this way:

$('#posteditor')
    .bootstrapValidator()
      .find('[name="text"]').ckeditor({
        skin: 'moono,/asset/css/moono/',
        language: 'it',
        toolbarGroups: [
          {"name":"basicstyles","groups":["basicstyles"]},
          {"name":"paragraph","groups":["list","align"]},
          {"name":"insert","groups":["insert"]},
          {"name":"styles","groups":["styles"]},
          {"name":"links","groups":["links"]},
        ],
        removeButtons: 'Strike,SpecialChar,Anchor',
        extraPlugins: 'youtube'
      }).editor.on('change', function() {
        $('#posteditor')
          .bootstrapValidator('updateStatus', 'text', 'NOT_VALIDATED')
          .bootstrapValidator('validateField', 'text');
      });

declaring it in my html in this way

<form id="posteditor">
....
  <textarea class="form-control" name="text" id="text"></textarea>
....
</form>

when the onchange event is fired, the javascript console shows the message

Uncaught TypeError: Cannot read property 'group' of undefined

and the field is not validated.

Thanks for your help


回答1:


The below works good,

$('#posteditor')
      .bootstrapValidator('updateStatus', $('#text'), 'NOT_VALIDATED')
      .bootstrapValidator('validateField', $('#text'));
  });

Or

 $('#posteditor').bootstrapValidator('revalidateField', $('#text'));



回答2:


Check whether you have accidentally added fv-* or bv-* attributes to any of the fields which in the html page and not in your form...

Also check whether your page has more than one input box with same name..

Because,While validating the validator selects all fields in the page and process only the inputs with field names in your initialization.

Moreover you can use http://jsbeautifier.org/ to deminify your bootstrapValidator.min.js and debug on your own to check your issue



来源:https://stackoverflow.com/questions/27620475/bootstrapvalidator-gives-cannot-read-property-group-of-undefined-on-ckeditor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!