Results 1 to 3 of 3
  1. #1
    Member clems365's Avatar
    Joined
    May 2007
    Posts
    56

    Set the minimum number of characters for the tags.

    Hi all

    Like the title story or story description, I would like to make the same for the tags clouds (min characters 4).

    I saw in the database and make a look :

    PHP Code:
    (71'Submit''minTitleLength''10''10''number''Minimum Title Length''Set the minimum number of characters for the story title.''define'NULL), 
    It could be something like that:

    PHP Code:
    (71'tags''minTagLength''4''4''number''Minimum Tags Length''Set the minimum number of characters for the tags.''define'NULL), 
    I believe it will be more or less the same, but... I don't now how to make it

    Somebody could help me

    Thanks a lot

    Best regards

    Clément

  2. #2
    Pligg Donor redwine's Avatar
    Joined
    Jul 2007
    Posts
    216

    Forcing a minimum number of characters

    There is no feature to set the number of characters for the tag word in the admin pannel. You might try this while users submit a story.

    Open /yourtemplate/submit_step_2.tpl and insert the following code within the {literal} {/literal}

    Code:
    <SCRIPT language="JavaScript">
    <!--
    function checkTags() {
     var tags=window.document.thisform.tags.value
      if (tags=="") {
       alert('Please enter at least one tag');
       window.document.thisform.tags.focus();
       exit;
      }
      if (tags.indexOf(",")== -1) {
       if (trim(tags).length < 4) {
        alert("The tag word must be at least 4 characters. Please correct it.");
       }
      }
      if (tags.indexOf(",")!= -1) {
       var tag_array=window.document.thisform.tags.value.split(",");
       var tags_num=0;
       while (tags_num < tag_array.length) {
        if (trim(tag_array[tags_num]).length < 4) {
           alert("The tag '" + tag_array[tags_num] + "' is less than 4 characters. Please correct it.");
          }
          tags_num+=1;
         }
      }
    }
     
    function trim(str) {
       return str.replace(/^\s+|\s+$/g,'');
    }
    //-->
    </SCRIPT>
    Go to this line where the input fields for the tags is and add the red part:
    Code:
    <input type="text" id="tags" name="tags" value="{$tags_words}" size="60" maxlength="40" onClick="checkTags();"/>
    Now, as soon as the Tags field looses focus. the function checks the following:
    1. If the Tags field is empty, it alerts the user, gives the focus back to this field and exit the function.
    2. If only one tag was entered (no comas), it trims the value and checks its length. If the length is less than 4, it sends an alert.
    3. If more than one tag were entered, it splits and iterates through the tags and checks the trimmed length for each. If the length is less than 4, it sends an alert.
    I hope this helps

  3. #3
    Member clems365's Avatar
    Joined
    May 2007
    Posts
    56
    many thanks I will try

Similar Threads

  1. How do I set minimum # of characters??
    By racerman28 in forum Questions & Comments
    Replies: 5
    Last Post: 01-13-2011, 01:43 AM
  2. Tags should have 4 letters minimum
    By Eddy in forum Questions & Comments
    Replies: 0
    Last Post: 05-20-2009, 05:30 AM
  3. Require minimum number of votes before posting
    By ratzo in forum Questions & Comments
    Replies: 1
    Last Post: 08-22-2008, 12:40 PM
  4. minimum characters on submit page
    By davebowker in forum Questions & Comments
    Replies: 3
    Last Post: 07-20-2008, 05:30 PM
  5. set a minimum limit on tags?
    By abraxas in forum Questions & Comments
    Replies: 0
    Last Post: 03-05-2008, 03:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Pligg Modules and Pligg Templates from Pligg Pro Donate to Pligg CMS Dreamhost Web Hosting Host Gator Web Hosting