javascript - TinyMCE limit characters typed by users -


i googled lot limiting characters in tinymce nothing working! how create message box if users type more 500 characters?

got it! new version uses ed.on("keydown", function(ed,evt) { instead of ed.onkeydown.add(function(ed, evt) {

so function becomes:

setup : function(ed) {                     var max_tekens = <?php echo $max_aantal_tekens_excl_opmaak; ?>;                     var beschikbaar_voor_opmaak = <?php echo ($max_aantal_tekens_incl_opmaak -                     $max_aantal_tekens_excl_opmaak); ?>;                     ed.on("keydown", function(ed,evt) {                       aantal_tekens_zonder_opmaak = tinymce.activeeditor.getcontent().replace(/(< ([^>]+)>)/ig,"").length;                       aantal_tekens_met_opmaak = tinymce.activeeditor.getcontent().length;                       var key = ed.keycode;                       $('#omschrijving_wijzigen_tekens').html(max_tekens - aantal_tekens_zonder_opmaak);                       if (aantal_tekens_met_opmaak > (max_tekens+beschikbaar_voor_opmaak)){                           alert('u hebt het maximaal aantal tekens nog niet helemaal bereikt, maar u gebruikt veel opmaak dat ook ruimte kost. verwijder tekens of gebruik minder opmaak (vet, cursief, ondertrepen).');                           ed.stoppropagation();                           ed.preventdefault();                       }                       else if (aantal_tekens_zonder_opmaak > max_tekens-1 && key != 8 && key != 46){                            alert('u hebt het maximaal aantal tekens bereikt.');                            ed.stoppropagation();                            ed.preventdefault();                       }                       else if(aantal_tekens_zonder_opmaak > (max_tekens - 25)){                           $('#omschrijving_wijzigen_max_tekens').css('color','red');                       }                        else {                           $('#omschrijving_wijzigen_max_tekens').css('color','gray');                       }                     });                 } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -