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

13.6k Views Asked by At

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

2

There are 2 best solutions below

0
On BEST ANSWER

The below works good,

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

Or

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

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