Results 1 to 3 of 3

Thread: textarea limitations

  1. #1
    Join Date
    Jul 2008
    Posts
    81
    Thanks
    38
    Thanked 2 Times in 2 Posts

    Default textarea limitations

    Hi,

    I have a textarea with 292px width.
    1) How can I force a break-line when the text is over 292px?
    2) How can I announce the user that the text is over 9 lines? (I want a limit of 9 lines)

    Thanks!

  2. #2
    Join Date
    Jul 2009
    Location
    Binus University
    Posts
    472
    Thanks
    78
    Thanked 21 Times in 21 Posts

    Default

    Got this from older post:
    Code:
    var maximumLength = 292;
    
    function checkLength(control, maximum) {
      var length = control.value.length;
    
      if (length > maximum) {
        alert('Please limit your message to ' + maximumLength
            + ' characters. There are currently ' + length + '.');
        return false;
      }
      return true;
    }
    
    function validate(form) {
      var controls = form.elements;
    
      if (!checkLength(controls.textArea, maximumLength))
        return false;
    
      return true;
    }
    Code:
    <form action="..." onsubmit="return validate(this);">
      <!-- ... -->
        <textarea ... onchange="checkLength(this, maximumLength);"></textarea>
      <!-- ... -->
    </form>
    gud luck
    _____________________

    David Demetrius // davejob
    _____________________

  3. The Following User Says Thank You to davelf For This Useful Post:

    lord22 (11-09-2009)

  4. #3
    Join Date
    Nov 2009
    Location
    Maputo, Mozambique, Africa
    Posts
    14
    Thanks
    3
    Thanked 1 Time in 1 Post

    Default

    Well i don't know how to count the 9 lines but you can wrap the text using the html tag wrap="soft" (without sending out the carriage returns) or wrap="hard" (sending out the carriage returns). I always use the soft one...

    Hope this can help a bit...

  5. The Following User Says Thank You to Piotto For This Useful Post:

    lord22 (11-09-2009)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •