Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Count the characters in tinymce [duplicate]

Is there any way by which I can count the characters entered in tinymce editor. I just want to set minimum character requirement. Or how to use tinyMCE.activeEditor.getContent() properly for this purpose.

like image 951
bɪˈɡɪnə Avatar asked Oct 20 '25 10:10

bɪˈɡɪnə


1 Answers

I believe that the better way to do this is using the getContent api:

// Get the HTML contents of the currently active editor
tinymce.activeEditor.getContent().length

// Get the raw text of the currently active editor
tinymce.activeEditor.getContent({format: 'text'}).length;

// Get content of a specific editor:
tinymce.get('content id').getContent().length

Please note the usage of the format parameter in the second example in order to get the raw text instead of the parsed text with HTML tags.

like image 171
roperzh Avatar answered Oct 22 '25 01:10

roperzh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!