Professional Web Applications Themes

Textarea - Limit Amount of Characters? - PHP Development

"Ralph Freshour" <ralphprimemail.com> wrote in message news:cr6bkvc5rsi9o355ff50c7746iu0omq6kk4ax.com... > Using PHP is there anyway to limit the number of characters a user > enters into a textarea control? I want to limit the text to 512 > characters. I suspect *limiting* the amount of text possible to enter into a textarea would be a client-side javascript problem, but you could trim a form variable down to 512 characters once the submitted from reaches the server. $clipped_string=substr($_POST['textarea'],0,512); It might be more user friendly if you direct the user back to the form, populating all the fields using the values from the original ...

  1. #1

    Default Re: Textarea - Limit Amount of Characters?


    "Ralph Freshour" <ralphprimemail.com> wrote in message
    news:cr6bkvc5rsi9o355ff50c7746iu0omq6kk4ax.com...
    > Using PHP is there anyway to limit the number of characters a user
    > enters into a textarea control? I want to limit the text to 512
    > characters.
    I suspect *limiting* the amount of text possible to enter into a textarea
    would be a client-side javascript problem, but you could trim a form
    variable down to 512 characters once the submitted from reaches the server.

    $clipped_string=substr($_POST['textarea'],0,512);

    It might be more user friendly if you direct the user back to the form,
    populating all the fields using the values from the original form, with the
    text area highlighted and maybe marked with a warning 'too many characters'.


    A possible javascript function could be

    function LimitLength(_object,textlength)
    {
    if(_object.value.length>textlength)
    {
    alert('You have exceeded the '+textlength+' character limit for a given
    text field. Please delete some of the text.');
    _object.focus();
    return false;
    }
    return true;
    }

    and in the form

    <textarea name="comment" onBlur="LimitLength(this,512);"></textarea>
    >
    > Thanks...
    >

    Richard Hockey Guest

  2. Moderated Post

    Default Re: Textarea - Limit Amount of Characters?

    Removed by Administrator
    Default User Guest
    Moderated Post

  3. Moderated Post

    Default Re: Textarea - Limit Amount of Characters?

    Removed by Administrator
    Ralph Freshour Guest
    Moderated Post

Similar Threads

  1. how to limit number of rows in a textarea
    By ryna in forum Macromedia Dynamic HTML
    Replies: 2
    Last Post: January 4th, 06:35 PM
  2. Show first 25 characters or so of textarea
    By sattman in forum Coldfusion - Getting Started
    Replies: 2
    Last Post: November 6th, 12:33 AM
  3. problems with some characters in TEXTAREA
    By alpenman in forum Macromedia ColdFusion
    Replies: 8
    Last Post: March 1st, 12:05 AM
  4. #16189 [Com]: limit in lenght of textarea from a php page
    By dario at designitup dot com in forum PHP Development
    Replies: 0
    Last Post: October 29th, 09:07 PM
  5. Is there a way to only allow a textarea to hold a certain # of characters?
    By mherchel webforumsuser@macromedia.com in forum Macromedia Dreamweaver
    Replies: 3
    Last Post: July 17th, 04:00 AM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139