javascript bootstrapvalidator 在 ckeditor 字段上给出“无法读取未定义的属性‘组’”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27620475/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
bootstrapvalidator gives "Cannot read property 'group' of undefined" on ckeditor field
提问by helloIAmPau
I'm using ckeditor on a text area and I need to set a custom validation.
我在文本区域使用 ckeditor,我需要设置自定义验证。
Following the example, I set the textbox using the jquery adapter in this way:
按照示例,我以这种方式使用 jquery 适配器设置文本框:
$('#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
以这种方式在我的 html 中声明它
<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
当 onchange 事件被触发时,javascript 控制台会显示消息
Uncaught TypeError: Cannot read property 'group' of undefined
and the field is not validated.
并且该字段未经过验证。
Thanks for your help
谢谢你的帮助
回答by Raj
The below works good,
下面的效果很好,
$('#posteditor')
.bootstrapValidator('updateStatus', $('#text'), 'NOT_VALIDATED')
.bootstrapValidator('validateField', $('#text'));
});
Or
或者
$('#posteditor').bootstrapValidator('revalidateField', $('#text'));
回答by Karthikeyan
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...
检查您是否不小心将 fv-* 或 bv-* 属性添加到 html 页面中而不是表单中的任何字段中...
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
此外,您可以使用http://jsbeautifier.org/来消除 bootstrapValidator.min.js 并自行调试以检查您的问题