Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty value should be empty? #143

Closed
marbetschar opened this issue Dec 30, 2013 · 21 comments

Comments

@marbetschar
Copy link

commented Dec 30, 2013

If the texteditor is empty the source view shows a

<p><br></p>

I think this should be empty, or at least

<p></p>

?

@ghost ghost assigned hackerwins Dec 31, 2013
@Remo

This comment has been minimized.

Copy link
Contributor

commented Mar 13, 2014

I'd definitely need an empty value, we're working with $.extend({}, and this is always causing some problems.

@abishekrsrikaanth

This comment has been minimized.

Copy link

commented Apr 7, 2014

My issue is in respect to this issue as well. How do I validate if the text editor is empty or not?

@DavidKrowitz

This comment has been minimized.

Copy link

commented Apr 11, 2014

Ya the code window should be empty if there is nothing in the editor.

This can be worked around by emptying the code editor if the field is empty on page load.

if (myField == null)
{
$('.HTMLEditor').code("");
}

@hackerwins hackerwins removed this from the v0.6.0 milestone Apr 26, 2014
@stefantalen

This comment has been minimized.

Copy link

commented Jun 27, 2014

👍 This should be default behaviour, if there is no content the value should be empty

@hackerwins hackerwins removed their assignment Jul 25, 2014
@lqez

This comment has been minimized.

Copy link
Member

commented Oct 24, 2014

For compatibility issue, initial paragraph should not be empty. (Ref #313)

However, it would be better to have isEmpty function to determine whether summernote is empty.
( I even wrote helper code to determine in django-summernote : https://github.com/lqez/django-summernote/blob/master/django_summernote/widgets.py#L46 )

@lqez

This comment has been minimized.

@inkub8

This comment has been minimized.

Copy link

commented Mar 8, 2015

I realise this is closed, but having a method call to determine this doesn't really work when you're trying to plug this in to a form validation library (e.g. Parsley). If I just wanted to check there was no value, I could run $(node).text().trim() === ''
I actually need the .code() to return an empty string to be honest.

@hackerwins

This comment has been minimized.

Copy link
Member

commented Jun 29, 2015

Empty <br> is necessary for focus. You can find focus problem by editing <p></p><p></p><p></p> with codeview(can't focus for second and third).

For workaround this, We support a external API for check empty contents.

var isEmpty = $('.summernote').summernote('isEmpty');
@hackerwins hackerwins closed this Jun 29, 2015
@kickthemooon

This comment has been minimized.

Copy link

commented Nov 12, 2015

Im still not sure how to remove:

<p><br></p>

?

@scasic

This comment has been minimized.

Copy link

commented Jan 16, 2016

Yep, how to remove default markup <p><br></p>?

@mariusz-peplinski

This comment has been minimized.

Copy link

commented Jan 27, 2016

Do not remove the default markup, as it causes problems (see posts above). When getting the value of your texarea, just do the following:

var myText = $('#myField').summernote('isEmpty')? '' : $('#myField').summernote('code');
@NikhilPrajapati

This comment has been minimized.

Copy link

commented Feb 5, 2016

Hi @marbetschar, I have the same issue while inserting your code. It will always shows empty string while summernote is filled up or not.

@arfo90

This comment has been minimized.

Copy link

commented Mar 28, 2016

Hi guys,

I also had similar issue with <p><br></p> . In my case, editor randomly put this break inside the returned code, even when you have text and filed is not empty. well it might not looks like a big deal but it generates wrong html string in my opinion which in some cases might breaks the system.

The fact that it is random, makes me a bit worried,

Thanks & regards,

@planetahuevo

This comment has been minimized.

Copy link

commented Jul 13, 2016

I have the same issue as @arfo90
It is generating
<br>
for each blank space on the code, so the result is not what the use saves.

Any ideas on how to fix it?

Thanks

@Mad-Chemist

This comment has been minimized.

Copy link

commented Oct 5, 2016

I'm experiencing this issue still, but only in FireFox... It appears as though the
tags do not get removed once the user starts typing..

@agenciahouse

This comment has been minimized.

Copy link

commented Feb 13, 2017

How to set empty, after sending with jquery ajax?

@mahfuzak08

This comment has been minimized.

Copy link

commented Jul 26, 2017

$('#id').summernote('isEmpty') not work properly. I'm facing same problem, and solved in this way -

var tempmsg = $("#msg").summernote('code');
tempmsg = tempmsg.replace(/


</p>/gi, '');
if(tempmsg == ''){
$("#id").summernote('reset');
}
else{
//write your code
}

@cartbinder

This comment has been minimized.

Copy link

commented Oct 27, 2018

In order to check on the place of usage, for me, it's the storefront.

I am checking like this:

if(strlen($message) == 11) {
//Write your code
}

Where the $message is the content from the summer note.

@rlirwin1138

This comment has been minimized.

Copy link

commented Nov 29, 2018

I'm using unobtrusive validation
How exactly am I supposed to use the IsEmpty method on that?

@netzah9

This comment has been minimized.

Copy link

commented Jun 20, 2019

I solved it validating each summernote input against this regexp:
/^(<p><br><\/p>$)/
If matches, it is an empty summernote.

@rbonestell

This comment has been minimized.

Copy link

commented Sep 19, 2019

This is truly a pain if you're using a framework to validate required fields on a textarea, now instead of marking a member on my model as required I have to use a custom regex validator...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.