www.webdeveloper.com
Results 1 to 10 of 10

Thread: textarea maxlength

  1. #1
    Join Date
    Oct 2004
    Location
    faraway Romania
    Posts
    471

    textarea maxlength

    it seems that maxlength="" works for <input type="text"> only.
    is there anything that will do the same for <textarea>?

    I am using php to error back messages longer than 1500 on my guestbook, but i assume it would be very annoying for people to have to delete what they have already written.
    The danger of religion lies in its most attractive feature. It is the arrogance that comes with thinking you possess the ultimate knowledge.

    .: My Web Development Site :: My Personal Site :.
    .: Web Design Quiz :: PHP/MySQL Quiz :: Test the Dvorak keyboard layout :.

  2. #2
    Join Date
    Dec 2004
    Posts
    1
    You will need to user javascript, unfortunately there is no standard html character limit solution. Here are a few examples you could deploy:

    http://www.google.com/search?sourcei...haracter+limit

    James

  3. #3
    Join Date
    Oct 2004
    Location
    faraway Romania
    Posts
    471
    well at least i didn't write all the php for nothing. the javascript i found doesn't look too big, so i'm gonna use it. thanks.
    The danger of religion lies in its most attractive feature. It is the arrogance that comes with thinking you possess the ultimate knowledge.

    .: My Web Development Site :: My Personal Site :.
    .: Web Design Quiz :: PHP/MySQL Quiz :: Test the Dvorak keyboard layout :.

  4. #4
    Join Date
    Dec 2004
    Posts
    54
    hey, try this one...

    <textarea name="name" rows="num1" cols="num2"></textarea>

    //Make sure that the product of num1 and num2 is equal to whatever
    //maximum length you want...

    -daimous

  5. #5
    Join Date
    Oct 2004
    Location
    faraway Romania
    Posts
    471
    rows and cols?

    the standards say the user agent should provide ways of scrolling when the length exceeds what can be held by the textarea.
    if you think about it, this makes sense.

    anyways, try it for yourself, it's not gonna work.
    The danger of religion lies in its most attractive feature. It is the arrogance that comes with thinking you possess the ultimate knowledge.

    .: My Web Development Site :: My Personal Site :.
    .: Web Design Quiz :: PHP/MySQL Quiz :: Test the Dvorak keyboard layout :.

  6. #6
    Join Date
    Dec 2004
    Posts
    54
    Last edited by daimous; 12-27-2004 at 08:16 PM.

  7. #7
    Join Date
    Dec 2004
    Posts
    54
    try this one for sure this will solve your problem nor answer your question...

    Click Me

    -daimous

  8. #8
    Join Date
    Nov 2002
    Location
    Auburn, AL
    Posts
    9,222
    Javascript will not work... not alone. Keep in mind not all browsers support it. Check the length of the string server side before you put it in the db. If I wanted to I could just exploit your script and spam the heck out of you if you do this with java script because I can just go up to my toolbar and uncheck javascript.

  9. #9
    Join Date
    Oct 2004
    Location
    faraway Romania
    Posts
    471
    PeOfEo, that's a very good point.

    What I decided in the end was to improve my PHP rather than use javascript.

    What I'm doing is use PHP to reject comments shorter than 100 chars or longer than 1500 chars.

    "I'm sorry but your post has 1600 characters and the limit is 1500"

    Then I take the information he entered and put it back into an identical form.

    So he is faced with the form as it was when he clicked submit. No need to click the back button (because the 'back button' on IE will erase anything entered into the textarea).

    The fact that users are informed that there is a 1500 limit but they do not know the length of their input (until they submit) will actually encourage them to be as succinct as possible and use a length way below this limit 'just to be sure'.

    Or at least that's my logic. I'll have to see this in action for a while to make sure I'm right.

    oh BTW, don't you think it would be better to keep political statements for political forums? I strongly support palestinian demands for statehood, freedom and justice yet you don't see me posting any flags or making political statements.
    The danger of religion lies in its most attractive feature. It is the arrogance that comes with thinking you possess the ultimate knowledge.

    .: My Web Development Site :: My Personal Site :.
    .: Web Design Quiz :: PHP/MySQL Quiz :: Test the Dvorak keyboard layout :.

  10. #10
    Join Date
    Nov 2002
    Location
    Auburn, AL
    Posts
    9,222
    Its is my custom user text feild and my avatar field. In it I chose to put some of my views. Nothing is stopping you from doing the same, as long as you do not put nudity or absenities in it. Also there is a fair ammount of political discussion that goes on in the coffee lounge forum.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles