counter - about word counter Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.
+2
Ange Tuteur
Ahmed.K
6 posters

    about word counter

    avatar
    Ahmed.K
    Forumember


    Posts : 347
    Reputation : 4
    Language : English

    In progress about word counter

    Post by Ahmed.K Thu 27 Nov - 3:23

    About this code:
    https://help.forumotion.com/t131882-just-one-last-change-at-the-word-counter#885030

    Code:
      $(function(){$(function(){

                   var MinNumberOfChars = 50;
                   var ico_compl = "http://i73.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
                   var ico_incompl = "http://i73.servimg.com/u/f73/18/10/89/49/exclam10.png";  
              
              if($("#text_editor_textarea").length != 0){
                      $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");      
                      $(".sceditor-container").after("<br/><div id='div_minchars' align='center'><div id='div_minchars_header'> Minimum characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
                      
                      var sceditor = $("#text_editor_textarea").sceditor("instance");                
                      var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
                      var str_len = str.length;
                      
                      if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
                      
                      sceditor.keyUp(function(e) {
                         str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
                         str_len = str.length;
                         if(str_len >= MinNumberOfChars) {
                            $("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(s). You can now send the message <img src='" + ico_compl  + "' />");  
                        $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
                         }else{
                            $("#div_minchars_info").html("You've written <span style='color:red'>" + str_len + "</span> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl  + "' />");
                            $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
                         }
                      });
                   }
                })});

    the code works fine. but ...
    It doesn't work when i copy/paste any text (of course more than 50 characters) without pressing any key on the keyboard.

    After searching in Google, I tested this ...
    sceditor.on('keyup change', function(e){
    instead of
    sceditor.keyUp(function(e) {

    But it doesn't work too. Any ideas?


    Last edited by Ahmed.K on Thu 27 Nov - 17:50; edited 1 time in total
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    In progress Re: about word counter

    Post by Ange Tuteur Thu 27 Nov - 3:52

    Hello Ahmed,

    Try replacing your script with this :
    Code:
      $(function(){$(function(){

                  var MinNumberOfChars = 50;
                  var ico_compl = "http://i73.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
                  var ico_incompl = "http://i73.servimg.com/u/f73/18/10/89/49/exclam10.png";
           
              if($("#text_editor_textarea").length != 0){
                      $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");   
                      $(".sceditor-container").after("<br/><div id='div_minchars' align='center'><div id='div_minchars_header'> Minimum characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
                   
                      var sceditor = $("#text_editor_textarea").sceditor("instance");             
                      var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
                      var str_len = str.length;
                   
                      if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
                   
                      $('.sceditor-container iframe').contents().on('input', function() { getLen() });
                      $('.sceditor-container textarea').on('input', function() { getLen() });
                      sceditor.keyUp(function() { getLen() });
                  }
                  function getLen() {
                        str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
                        str_len = str.length;
                        if(str_len >= MinNumberOfChars) {
                            $("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(s). You can now send the message <img src='" + ico_compl  + "' />");
                        $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
                        }else{
                            $("#div_minchars_info").html("You've written <span style='color:red'>" + str_len + "</span> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl  + "' />");
                            $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
                        }
                  }
                })});
    avatar
    Ahmed.K
    Forumember


    Posts : 347
    Reputation : 4
    Language : English

    In progress Re: about word counter

    Post by Ahmed.K Thu 27 Nov - 4:46

    It works now!
    But can we count only the letters (english letters) and numbers? Not #, $ , . *,....
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    In progress Re: about word counter

    Post by Ange Tuteur Thu 27 Nov - 13:08

    Try now :
    Code:
      $(function(){$(function(){

                  var MinNumberOfChars = 50;
                  var ico_compl = "http://i73.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
                  var ico_incompl = "http://i73.servimg.com/u/f73/18/10/89/49/exclam10.png";
         
              if($("#text_editor_textarea").length != 0){
                      $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5"); 
                      $(".sceditor-container").after("<br/><div id='div_minchars' align='center'><div id='div_minchars_header'> Minimum characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
                 
                      var sceditor = $("#text_editor_textarea").sceditor("instance");           
                      var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
                      var str_len = str.length;
                 
                      if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
                 
                      $('.sceditor-container iframe').contents().on('input', function() { getLen() });
                      $('.sceditor-container textarea').on('input', function() { getLen() });
                      sceditor.keyUp(function() { getLen() });
                  }
                  function getLen() {
                        str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:|[!@#$%\^&\*\(\)\[\]`~;:'"<,>\.\?\/_-=+]+/gi,'');
                        str_len = str.length;
                        if(str_len >= MinNumberOfChars) {
                            $("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(s). You can now send the message <img src='" + ico_compl  + "' />");
                        $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
                        }else{
                            $("#div_minchars_info").html("You've written <span style='color:red'>" + str_len + "</span> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl  + "' />");
                            $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
                        }
                  }
                })});

    I added some characters to the filter.
    avatar
    Ahmed.K
    Forumember


    Posts : 347
    Reputation : 4
    Language : English

    In progress Re: about word counter

    Post by Ahmed.K Thu 27 Nov - 14:58

    Doesn't work.
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    In progress Re: about word counter

    Post by Ange Tuteur Thu 27 Nov - 15:03

    Oops, I made a mistake, try now :
    Code:
      $(function(){$(function(){

                  var MinNumberOfChars = 50;
                  var ico_compl = "http://i73.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
                  var ico_incompl = "http://i73.servimg.com/u/f73/18/10/89/49/exclam10.png";
       
              if($("#text_editor_textarea").length != 0){
                      $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
                      $(".sceditor-container").after("<br/><div id='div_minchars' align='center'><div id='div_minchars_header'> Minimum characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
               
                      var sceditor = $("#text_editor_textarea").sceditor("instance");         
                      var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
                      var str_len = str.length;
               
                      if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
               
                      $('.sceditor-container iframe').contents().on('input', function() { getLen() });
                      $('.sceditor-container textarea').on('input', function() { getLen() });
                      sceditor.keyUp(function() { getLen() });
                  }
                  function getLen() {
                        str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:|[!@#$%\^&\*\(\)\[\]`~;:'"<,>\.\?\/\_\-\=\+]+/gi,'');
                        str_len = str.length;
                        if(str_len >= MinNumberOfChars) {
                            $("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(s). You can now send the message <img src='" + ico_compl  + "' />");
                        $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
                        }else{
                            $("#div_minchars_info").html("You've written <span style='color:red'>" + str_len + "</span> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl  + "' />");
                            $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
                        }
                  }
                })});
    avatar
    Ahmed.K
    Forumember


    Posts : 347
    Reputation : 4
    Language : English

    In progress Re: about word counter

    Post by Ahmed.K Thu 27 Nov - 15:21

    It works well, but what about the english letters?
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    In progress Re: about word counter

    Post by Ange Tuteur Thu 27 Nov - 15:32

    They should be counted. Isn't that what you wanted ?
    avatar
    Ahmed.K
    Forumember


    Posts : 347
    Reputation : 4
    Language : English

    In progress Re: about word counter

    Post by Ahmed.K Thu 27 Nov - 15:37

    Yes, i mean only the english letters should be counted, not any language else.
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    In progress Re: about word counter

    Post by Ange Tuteur Thu 27 Nov - 16:29

    Try this then :
    Code:
      $(function(){$(function(){

                  var MinNumberOfChars = 50;
                  var ico_compl = "http://i73.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
                  var ico_incompl = "http://i73.servimg.com/u/f73/18/10/89/49/exclam10.png";
     
              if($("#text_editor_textarea").length != 0){
                      $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
                      $(".sceditor-container").after("<br/><div id='div_minchars' align='center'><div id='div_minchars_header'> Minimum characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
             
                      var sceditor = $("#text_editor_textarea").sceditor("instance");       
                      var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
                      var str_len = str.length;
             
                      if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
             
                      $('.sceditor-container iframe').contents().on('input', function() { getLen() });
                      $('.sceditor-container textarea').on('input', function() { getLen() });
                      sceditor.keyUp(function() { getLen() });
                  }
                  function getLen() {
                        str = sceditor.val().replace(/\W/gi,'');
                        str_len = str.length;
                        if(str_len >= MinNumberOfChars) {
                            $("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(s). You can now send the message <img src='" + ico_compl  + "' />");
                        $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
                        }else{
                            $("#div_minchars_info").html("You've written <span style='color:red'>" + str_len + "</span> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl  + "' />");
                            $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
                        }
                  }
                })});
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51554
    Reputation : 3524
    Language : English
    Location : United States

    In progress Re: about word counter

    Post by SLGray Thu 27 Nov - 17:35

    Please change the title of your topic to something that is related to your question/issue, so that other users will be able to find their question/issue using the search engine.




    counter - about word counter Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.
    avatar
    Ahmed.K
    Forumember


    Posts : 347
    Reputation : 4
    Language : English

    In progress Re: about word counter

    Post by Ahmed.K Thu 27 Nov - 17:55

    This one works perfect, Ange.
    But can you disable counting the emoticon?

    Emoticon like this: :sm015: :sm01: :sm019: :sm09: :sm04: :sm05: :sm06:
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    In progress Re: about word counter

    Post by Ange Tuteur Thu 27 Nov - 18:00

    Code:
      $(function(){$(function(){

                  var MinNumberOfChars = 50;
                  var ico_compl = "http://i73.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
                  var ico_incompl = "http://i73.servimg.com/u/f73/18/10/89/49/exclam10.png";
     
              if($("#text_editor_textarea").length != 0){
                      $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
                      $(".sceditor-container").after("<br/><div id='div_minchars' align='center'><div id='div_minchars_header'> Minimum characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
           
                      var sceditor = $("#text_editor_textarea").sceditor("instance");     
                      var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
                      var str_len = str.length;
           
                      if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
           
                      $('.sceditor-container iframe').contents().on('input', function() { getLen() });
                      $('.sceditor-container textarea').on('input', function() { getLen() });
                      sceditor.keyUp(function() { getLen() });
                  }
                  function getLen() {
                    str = sceditor.val().replace(/(:.*?:|\W)/gi,'');
                        str_len = str.length;
                        if(str_len >= MinNumberOfChars) {
                            $("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(s). You can now send the message <img src='" + ico_compl  + "' />");
                        $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
                        }else{
                            $("#div_minchars_info").html("You've written <span style='color:red'>" + str_len + "</span> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl  + "' />");
                            $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
                        }
                  }
                })});
    avatar
    Ahmed.K
    Forumember


    Posts : 347
    Reputation : 4
    Language : English

    In progress Re: about word counter

    Post by Ahmed.K Thu 27 Nov - 18:15

    This one is solved too.
    Last thing Smile Can you disable counting anything between this [quote ][/quote] too?
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    In progress Re: about word counter

    Post by _Twisted_Mods_ Thu 27 Nov - 19:18

    this should work

    Code:
      $(function(){$(function(){

                  var MinNumberOfChars = 50;
                  var ico_compl = "http://i73.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
                  var ico_incompl = "http://i73.servimg.com/u/f73/18/10/89/49/exclam10.png";
     
              if($("#text_editor_textarea").length != 0){
                      $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
                      $(".sceditor-container").after("<br/><div id='div_minchars' align='center'><div id='div_minchars_header'> Minimum characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
         
                      var sceditor = $("#text_editor_textarea").sceditor("instance");   
                      var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[quote\].*?\[\/quote\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
                      var str_len = str.length;
         
                      if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
         
                      $('.sceditor-container iframe').contents().on('input', function() { getLen() });
                      $('.sceditor-container textarea').on('input', function() { getLen() });
                      sceditor.keyUp(function() { getLen() });
                  }
                  function getLen() {
                    str = sceditor.val().replace(/(:.*?:|\W)/gi,'');
                        str_len = str.length;
                        if(str_len >= MinNumberOfChars) {
                            $("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(s). You can now send the message <img src='" + ico_compl  + "' />");
                        $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
                        }else{
                            $("#div_minchars_info").html("You've written <span style='color:red'>" + str_len + "</span> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl  + "' />");
                            $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
                        }
                  }
                })});
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    In progress Re: about word counter

    Post by Ange Tuteur Thu 27 Nov - 20:46

    Not sure, but try this :
    Code:
      $(function(){$(function(){

                  var MinNumberOfChars = 50;
                  var ico_compl = "http://i73.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
                  var ico_incompl = "http://i73.servimg.com/u/f73/18/10/89/49/exclam10.png";
     
              if($("#text_editor_textarea").length != 0){
                      $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
                      $(".sceditor-container").after("<br/><div id='div_minchars' align='center'><div id='div_minchars_header'> Minimum characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
         
                      var sceditor = $("#text_editor_textarea").sceditor("instance");   
                      var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
                      var str_len = str.length;
         
                      if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
         
                      $('.sceditor-container iframe').contents().on('input', function() { getLen() });
                      $('.sceditor-container textarea').on('input', function() { getLen() });
                      sceditor.keyUp(function() { getLen() });
                  }
                  function getLen() {
                    str = sceditor.val().replace(/(:.*?:|\[.*?\].*?\[\/.*?\]|\W)/gi,'');
                        str_len = str.length;
                        if(str_len >= MinNumberOfChars) {
                            $("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(s). You can now send the message <img src='" + ico_compl  + "' />");
                        $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
                        }else{
                            $("#div_minchars_info").html("You've written <span style='color:red'>" + str_len + "</span> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl  + "' />");
                            $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
                        }
                  }
                })});
    avatar
    Ahmed.K
    Forumember


    Posts : 347
    Reputation : 4
    Language : English

    In progress Re: about word counter

    Post by Ahmed.K Fri 28 Nov - 2:52

    @_Twisted_Mods_, no, doesn't work.

    @Ange, yes, it works good in the quickreply mode, when i copy/paste any quote [quote ][/quote].
    But when i click on the quote button on any post and i go to the advanced mode, i find the Send button is enable. and i can send without writing anything. but when i start to write anything less than 50, i find that the Send button is disabled.
    And doesn't work at all if the quote like this: [quote="Admin"]test [b]test[ /b] test [ /quote].
    avatar
    Ahmed.K
    Forumember


    Posts : 347
    Reputation : 4
    Language : English

    In progress Re: about word counter

    Post by Ahmed.K Sat 29 Nov - 1:51

    No solution to this problem?
    avatar
    ryanzkie
    New Member


    Posts : 1
    Reputation : 1
    Language : english

    In progress Re: about word counter

    Post by ryanzkie Sat 29 Nov - 2:14

    bwi bwi bwi bwi bwi bwi bwi bwi bwi
    what a good day:
    Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Hello Hello Hello Hello Hello Hello
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51554
    Reputation : 3524
    Language : English
    Location : United States

    In progress Re: about word counter

    Post by SLGray Sat 29 Nov - 2:31

    ryanzkie wrote:bwi bwi bwi bwi bwi bwi bwi bwi bwi
    what a good day:
    Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Hello Hello Hello Hello Hello Hello
    Please do not reply unless you are offering a solution.



    counter - about word counter Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    In progress Re: about word counter

    Post by Ange Tuteur Sat 29 Nov - 3:10

    You can try this :
    Code:
      $(function(){$(function(){

                 var MinNumberOfChars = 50;
                 var ico_compl = "http://i73.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
                 var ico_incompl = "http://i73.servimg.com/u/f73/18/10/89/49/exclam10.png";

             if($("#text_editor_textarea").length != 0){
                     $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
                     $(".sceditor-container").after("<br/><div id='div_minchars' align='center'><div id='div_minchars_header'> Minimum characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
       
                     var sceditor = $("#text_editor_textarea").sceditor("instance");  
                     var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
                     var str_len = str.length;
       
                     if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
       
                     $('.sceditor-container iframe').contents().on('input', function() { getLen() });
                     $('.sceditor-container textarea').on('input', function() { getLen() });
                     sceditor.keyUp(function() { getLen() });
                 }
                 function getLen() {
                   str = sceditor.val().replace(/(:.*?:|\W)/gi,'').replace(/\[.*?\].*?\[\/.*?\]/,'');
                       str_len = str.length;
                       if(str_len >= MinNumberOfChars) {
                           $("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(s). You can now send the message <img src='" + ico_compl  + "' />");
                       $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
                       }else{
                           $("#div_minchars_info").html("You've written <span style='color:red'>" + str_len + "</span> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl  + "' />");
                           $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
                       }
                 }
               })});
    avatar
    Ahmed.K
    Forumember


    Posts : 347
    Reputation : 4
    Language : English

    In progress Re: about word counter

    Post by Ahmed.K Sat 29 Nov - 7:16

    Still doesn't work. It is still counting everything between the quote.
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    In progress Re: about word counter

    Post by Ange Tuteur Sat 29 Nov - 9:15

    Okay, give this a try :

    Code:
      $(function(){$(function(){

                var MinNumberOfChars = 50;
                var ico_compl = "http://i73.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
                var ico_incompl = "http://i73.servimg.com/u/f73/18/10/89/49/exclam10.png";

            if($("#text_editor_textarea").length != 0){
                    $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
                    $(".sceditor-container").after("<br/><div id='div_minchars' align='center'><div id='div_minchars_header'> Minimum characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
     
                    var sceditor = $("#text_editor_textarea").sceditor("instance"); 
                    var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
                    var str_len = str.length;
     
                    if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
     
                    $('.sceditor-container iframe').contents().on('input', function() { getLen() });
                    $('.sceditor-container textarea').on('input', function() { getLen() });
                    sceditor.keyUp(function() { getLen() });
                }
                function getLen() {
                  str = sceditor.val().replace(/\[.*?\].*?\[\/.*?\]/g,'').replace(/(:.*?:|\W)/gi,'');
                      str_len = str.length;
                      if(str_len >= MinNumberOfChars) {
                          $("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(s). You can now send the message <img src='" + ico_compl  + "' />");
                      $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
                      }else{
                          $("#div_minchars_info").html("You've written <span style='color:red'>" + str_len + "</span> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl  + "' />");
                          $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
                      }
                }
              })});
    avatar
    Ahmed.K
    Forumember


    Posts : 347
    Reputation : 4
    Language : English

    In progress Re: about word counter

    Post by Ahmed.K Sat 29 Nov - 10:38

    No , still doesn't work if the quote like this: [quote="Admin"]test [b]test[ /b] test [ /quote].
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    In progress Re: about word counter

    Post by Ange Tuteur Sun 30 Nov - 0:23

    Okay, see if this works for the quotes :
    Code:
      $(function(){$(function(){

                var MinNumberOfChars = 50;
                var ico_compl = "http://i73.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
                var ico_incompl = "http://i73.servimg.com/u/f73/18/10/89/49/exclam10.png";

            if($("#text_editor_textarea").length != 0){
                    $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
                    $(".sceditor-container").after("<br/><div id='div_minchars' align='center'><div id='div_minchars_header'> Minimum characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
     
                    var sceditor = $("#text_editor_textarea").sceditor("instance");
                    var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
                    var str_len = str.length;
     
                    if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
     
                    $('.sceditor-container iframe').contents().on('input', function() { getLen() });
                    $('.sceditor-container textarea').on('input', function() { getLen() });
                    sceditor.keyUp(function() { getLen() });
                }
                function getLen() {
                  str = sceditor.val().replace(/(\[quote\]|\[quote=".*?"\]).*?\[\/quote\]/g,'').replace(/(:.*?:|\W)/gi,'');
                      str_len = str.length;
                      if(str_len >= MinNumberOfChars) {
                          $("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(s). You can now send the message <img src='" + ico_compl  + "' />");
                      $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
                      }else{
                          $("#div_minchars_info").html("You've written <span style='color:red'>" + str_len + "</span> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl  + "' />");
                          $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
                      }
                }
              })});

    Also, your example has a space in the tag. If there's a space it wont format after posting or be replace by the regex.
    avatar
    Ahmed.K
    Forumember


    Posts : 347
    Reputation : 4
    Language : English

    In progress Re: about word counter

    Post by Ahmed.K Sun 30 Nov - 1:59

    Yes, i know.... I did that to show the example here.

    The last code doesn't work with multiquote. like this:
    Code:
    [quote="Admin"][quote="User"]text[/quote][/quote]
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    In progress Re: about word counter

    Post by Ange Tuteur Sun 30 Nov - 2:28

    It seems to still work partially from what you've given.

    I'm out of ideas for now, sorry.
    avatar
    Ahmed.K
    Forumember


    Posts : 347
    Reputation : 4
    Language : English

    In progress Re: about word counter

    Post by Ahmed.K Sun 30 Nov - 14:39

    I think i found an old solution by you, and it works fine with the multiquote mode.
    https://help.forumotion.com/t134045-editor-word-counter#902533

    I think we can use this part in our code to solve the multiquote problem:
    Code:
    str = sceditor.val().replace(/\n/g,' ').replace(/\[quote=".*?"\].*?\[\/quote\]/gi,'').replace(/\[quote\].*?\[\/quote\]/gi,'').replace(/\[\/quote\]/gi,'').replace(/\[quote\]/gi,'').replace(/\[quote=".*?"\]/gi,'');


    But the only problem with this old solution, it counting the spaces in the quote.
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    In progress Re: about word counter

    Post by Ange Tuteur Sun 30 Nov - 20:38

    Okay, give this a try :
    Code:
      $(function(){$(function(){

                var MinNumberOfChars = 50;
                var ico_compl = "http://i73.servimg.com/u/f73/18/10/89/49/ok-gre10.png";
                var ico_incompl = "http://i73.servimg.com/u/f73/18/10/89/49/exclam10.png";

            if($("#text_editor_textarea").length != 0){
                    $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
                    $(".sceditor-container").after("<br/><div id='div_minchars' align='center'><div id='div_minchars_header'> Minimum characters to send a message: " + MinNumberOfChars + " </div><div id='div_minchars_info'></div></div>");
     
                    var sceditor = $("#text_editor_textarea").sceditor("instance");
                    var str = sceditor.val().replace(/ |\n|\s+|\[img\].*?\[\/img\]|\[.*?\]|\[\/.*?\]|:.*?:/gi,'');
                    var str_len = str.length;
     
                    if(str_len >= MinNumberOfChars) $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
     
                    $('.sceditor-container iframe').contents().on('input', function() { getLen() });
                    $('.sceditor-container textarea').on('input', function() { getLen() });
                    sceditor.keyUp(function() { getLen() });
                }
                function getLen() {
                  str = sceditor.val().replace(/\n/g,' ').replace(/\[quote=".*?"\].*?\[\/quote\]/gi,'').replace(/\[quote\].*?\[\/quote\]/gi,'').replace(/\[\/quote\]/gi,'').replace(/\[quote\]/gi,'').replace(/\[quote=".*?"\]/gi,'').replace(/(:.*?:|\W)/gi,'');
                      str_len = str.length;
                      if(str_len >= MinNumberOfChars) {
                          $("#div_minchars_info").html("You've written <span style='color:green'>" + str_len + "</span> character(s). You can now send the message <img src='" + ico_compl  + "' />");
                      $("input[type='submit'][name='post']").attr("disabled", false).css("opacity", "1");
                      }else{
                          $("#div_minchars_info").html("You've written <span style='color:red'>" + str_len + "</span> character(s). You need " + (MinNumberOfChars - str_len) + " character(s) to send this message <img src='" + ico_incompl  + "' />");
                          $("input[type='submit'][name='post']").attr("disabled", true).css("opacity", "0.5");
                      }
                }
              })});
    avatar
    Ahmed.K
    Forumember


    Posts : 347
    Reputation : 4
    Language : English

    In progress Re: about word counter

    Post by Ahmed.K Mon 1 Dec - 3:03


    Finally, Ange, the code now understand the multiquote system in the default mode (without any text) like this:
    Code:
    [quote="Admin"][quote="User"][quote="User1"][/quote][/quote][/quote]

    but still there one problem.
    the code works well and doesn't count the text in the first quote, like this (text1):

    Code:
    [quote="Admin"][quote="User"][quote="User1"]   text1   [/quote][/quote][/quote]


    but it count the text in the second and third quote, like this (text2 and text3):

    Code:
    [quote="Admin"][quote="User"][quote="User1"]   text1   [/quote]   text2   [/quote]   text3   [/quote]