jquery-validation: Summernote compatibility - "Cannot read property 'replace' of undefined"
Subject of the issue
Validating a form containing a Summernote WYSIWYG field causes error.Your environment
- Version of jquery-validate: 1.15.1
- Version of summernote: 0.8.2
- Browser: Chrome 54.0.2840.71
Steps to reproduce
Validate form containing Summernote fieldType inside form then blur / trigger validation
https://jsfiddle.net/benember/b0xchnnp/6/
Expected behaviour
Field validatesActual behaviour
Console error:jquery.validate.js:1014 <br> Uncaught TypeError: Cannot read property 'replace' of undefined
I Think this is related to: #1785 Which should have been merged into 1.15.1
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 27 (7 by maintainers)
@jeremycook You can do the same using
jQuery.validator.setDefaults()
:Please change from
to
Thanks.
@bennybee @r0lan2 See the following code. I explained a little what happened and what should be done in order to make
Summernote
to work withjQuery-validation
.Hi all I just want make one addition update to this issue: if you are using bootstrap 4 and obviously panel has been replaced by card. So one of the line in the resolution can be now replaced:
ignore: ":hidden:not(#summernote),.note-editable.panel-body"
withignore: ":hidden:not(#summernote),.note-editable.card-block"
why i am still getting this error in asp.net mvc 5 with latest version?
<div class="form-group"> <label class="control-label col-md-3 col-sm-3 col-xs-12" for="CommentText"> Remark <span class="required">*</span> </label> <div class="col-md-6 col-sm-6 col-xs-12"> <textarea name="CommentText" id="CommentText"></textarea> </div> </div>
here is my js code:
var v = $('#fromRiskUnit').validate({ ignore: ":hidden:not(#CommentText),.note-editable.panel-body" }); $('#CommentText') .summernote({ focus: true, height: 150, codemirror: { theme: 'united' } });
I am not validation this input, if the input has value, then I focus the other input, the error will throw.@JeffreyChan @MrChriZ @paulgabronis @Arkni I use this script to tell the validator to ignore Summernote elements. It can be tweaked to ignore elements generated by other HTML editors.
Actually I am getting the same error as @bennybee, I am using summernote v0.8.2 with asp.net mvc 5.
It works only on submit. The ignore does not work for onfocusout 😦
This works like a charm also for emojionearea. Without :hidden ofcourse.
@Arkni Arkni Thank you for the reply. I figured it out myself! actually it was really simple. I was using old version and as I changed it with latest one, the error disappeared!
Just tested with 1.16.0-pre and still got the same error