I limited the number of characters that can be added as content for a special page (event submission page). It works fine in text or code mode in WordPress but not when I use the WYSIWYG editor.
Any idea how to change it so it also works using the WordPress editor?
Thank you so much!
Here is the JS I am using.
// Set your character limit
var count_limit = 1000;
// Set the initial symbol count on page load
$('#tcepostcontent-wc span').html($('#tcepostcontent').val());
$('#tcepostcontent').on('keyup', function () {
var char_count = $(this).val().length;
var tcepostcontent = $(this).val();
var text_remaining = count_limit - char_count;
// Update the character count on every key up
$('#tcepostcontent-wc span').html(text_remaining);
if (char_count >= count_limit) {
$('#tcepostcontent-wc').css('color', 'red');
$(this).val(tcepostcontent.substr(1, count_limit));
} else {
$('#tcepostcontent-wc').css('color', null);
}
}).after('<p id="tcepostcontent-wc">Max 1000 are available <span>1000</span></p>');