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.
The forum of the forums
3 posters

    A script for Minimum letters on reply

    Nehelenia
    Nehelenia
    New Member


    Posts : 2
    Reputation : 1
    Language : English/Greek

    Solved A script for Minimum letters on reply

    Post by Nehelenia 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 https://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.
    avatar
    fascicularia
    Forumember


    Posts : 172
    Reputation : 1
    Language : french

    Solved Re: A script for Minimum letters on reply

    Post by fascicularia 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;
    Nehelenia
    Nehelenia
    New Member


    Posts : 2
    Reputation : 1
    Language : English/Greek

    Solved Re: A script for Minimum letters on reply

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

    It's perfect! Thank you!!
    SLGray
    SLGray
    Administrator
    Administrator


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

    Solved Re: A script for Minimum letters on reply

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

    Topic solved and archived



    A script for Minimum letters on reply Slgray10

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

      Current date/time is November 13th 2024, 7:29 pm