Results 1 to 5 of 5

Thread: minimum amount of words in text boxs

  1. #1
    Join Date
    Oct 2007
    Location
    UK Essex
    Posts
    591

    Default minimum amount of words in text boxs

    how can you set a minimum ammount of words for a textbox in indexu?

    say 250 bare min for the description field?


  2. #2
    Join Date
    Jun 2002
    Location
    Winnipeg Canada
    Posts
    4,913

    Default

    <script>
    function CheckLength()
    {
    var msg_area = document.getElementById("Message");
    msg_area.innerHTML = "";
    if (document.getElementById("comments").value.leng th < 20) {
    msg_area.innerHTML = "YOU DID NOT ENTER ENOUGH INFORMATION";
    }
    else document.getElementById("testform").submit();
    }
    </script>

    Modify to your requirements

  3. #3
    Join Date
    Oct 2007
    Location
    UK Essex
    Posts
    591

    Default

    these scripts only work if input type="button" not input type="submit".

    indexu simply refuses to submit it the input type is set to button.

    from what i can gather if the script was working with input type="submit" the user would recive the minimum ammount of character warning acordingly BUT the form would still submit anyway.

    I have tried two scripts now but they require input type="button" to be enabled.

    The next problem when i get this working will be knowing how to apply this to more than one <textarea>

    good things come to those who struggle

  4. #4
    Join Date
    May 2007
    Location
    NJ, United States
    Posts
    1,651

    Default

    Quote Originally Posted by echo@ View Post
    good things come to those who struggle
    If that was true... I'd have the PERFECT life!
    FSGDAG | IndexU Hosting | Owner
    Website | NiceCoder Script Hosting and More! | Web4URL is For Sale!
    Follow Us On Twitter | FaceBook Profile | YouTube Videos

  5. #5
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    Quote Originally Posted by echo@ View Post
    how can you set a minimum ammount of words for a textbox in indexu?

    say 250 bare min for the description field?

    are you looking for words or characters....???

    if you are looking for characters, you can use javascript (getElementById) to test the length of field and change your onsubmit to return a true / false value. something like onsubmit="javascript:return ValidateMinFields(this)". Test as many fields as you like. If one fails the test, popup an alert message and the form is not submitted.

    if you are testing for a minimum number of words, you will need to use the javascript split function instead of the length function.

    then in the add.php/modify.php test the fields again using the PHP explode function to test for words or the strlen function to test for characters. (NEVER RELY SOLELY ON JAVASCRIPT TO VALIDATE A FORM). If they don't pass the test there, send the user back to the form with the appropriate message.




    .
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

Similar Threads

  1. Replies: 8
    Last Post: 06-16-2007, 02:51 PM
  2. Minimum soze of the description
    By linksor.com in forum Blocks and Modification
    Replies: 5
    Last Post: 05-07-2007, 02:16 AM
  3. Amount of links displayed per page.
    By lewisw in forum v3.2
    Replies: 3
    Last Post: 08-18-2003, 06:12 PM
  4. Ratings, limiting amount or deleting?
    By starchdoggy in forum Pre-Sales Questions
    Replies: 3
    Last Post: 09-08-2002, 01:33 PM
  5. Hot links ! Amount ?
    By Nanard Of Web in forum Pre-Sales Questions
    Replies: 1
    Last Post: 07-24-2002, 01:30 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
  •