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.

Word counter doesn't work

4 posters

Go down

Solved Word counter doesn't work

Post by Vitavili May 17th 2015, 10:49 pm

Hello, 
 
I tried using this javascript code on my forum: http://testforum.lithuanianforum.net/ , but it doesn't work. Any ideas?


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");
                     }
                  });
               }
            })});

Word counter doesn't work Kfkffk10


Last edited by Vitavili on May 17th 2015, 11:10 pm; edited 2 times in total
Vitavili
Vitavili
New Member

Female Posts : 23
Reputation : 1
Language : English, Russian, Lithuanian, Spanish
Location : Vilnius, Lithuanian

http://deliciousperfection.forumotions.net/

Back to top Go down

Solved Re: Word counter doesn't work

Post by darki May 17th 2015, 10:55 pm

Try this one: Click.

It's in progress in my forum and works fine. It counts words and chars and appears below the editor.
avatar
darki
Forumember

Posts : 254
Reputation : 10
Language : German, english

http://schiggysboard.com

Back to top Go down

Solved Re: Word counter doesn't work

Post by Van-Helsing May 17th 2015, 11:02 pm

Hello @Vitavili,
I just test your code on my testing forum and it seems working fine

Word counter doesn't work YD0CT2k

have you set your javascript In the topics?
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Solved Re: Word counter doesn't work

Post by Vitavili May 17th 2015, 11:10 pm

darki, thanks for the code, but the problem was that I set it on all pages not in the topics. Thanks @Black-Shadow !

Solved Smile
Vitavili
Vitavili
New Member

Female Posts : 23
Reputation : 1
Language : English, Russian, Lithuanian, Spanish
Location : Vilnius, Lithuanian

http://deliciousperfection.forumotions.net/

Back to top Go down

Solved Re: Word counter doesn't work

Post by SLGray May 17th 2015, 11:51 pm

Topic solved and archived


Word counter doesn't work Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

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

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum