The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

A script for Minimum letters on reply

View previous topic View next topic Go down

Solved A script for Minimum letters on reply

Post by Nehelenia on May 2nd 2015, 8:32 pm

Hello everyone,
On my forum I got some topics with hidden contend that you need to post a reply in order to see it. I got a problem with some users that tend to give really sort replies like "!" "!!" "tnx". Is there a scrip that will make the replies to require a minimum of at leasts 4 letters in order to post?
I tried this one http://help.forumotion.com/t121475-minimum-character-post?highlight=minimum+characters
but I post a reply even when I typed a whole sentence. I tried editing the numbers on the script but nothing changed.
Could someone please help me?
Thank you very much for your time. I really appreciate it. I hate banning people.

Nehelenia
New Member

Posts : 2
Reputation : 1
Language : English/Greek

http://wingsofdestiny.forumotion.net

Back to top Go down

Solved Re: A script for Minimum letters on reply

Post by fascicularia on May 2nd 2015, 8:55 pm

Hi Nehelenia, 
try this

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

                  var MinNumberOfChars = 4;
                  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");
                        }
                      });
                  }
                })});


To change the number of characters, you must change this part /
Code:
 var MinNumberOfChars = 4;

fascicularia
Forumember

Posts : 100
Reputation : 1
Language : french

Back to top Go down

Solved Re: A script for Minimum letters on reply

Post by Nehelenia on May 2nd 2015, 9:01 pm

It's perfect! Thank you!!

Nehelenia
New Member

Posts : 2
Reputation : 1
Language : English/Greek

http://wingsofdestiny.forumotion.net

Back to top Go down

Solved Re: A script for Minimum letters on reply

Post by SLGray on May 2nd 2015, 9:19 pm

Topic solved and archived


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


SLGray
Administrator
Administrator

Male Posts : 35613
Reputation : 2372
Language : English
Location : United States

http://fmthemes.forumotion.com/

Back to top Go down

View previous topic View next topic Back to top


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