Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Limiting characters in textarea

  • 17-12-2001 10:01am
    #1
    Closed Accounts Posts: 1,651 ✭✭✭


    Does anyone know if its possible to limit the number of characters typed into a textarea?
    Without using Javascript?


Comments

  • Closed Accounts Posts: 512 ✭✭✭beaver


    AFAIK it's not.


  • Registered Users, Registered Users 2 Posts: 944 ✭✭✭nahdoic


    I don't think it's possible either. The input text fields have the maxlength option, but the textarea doesn't.

    Why don't you want to use javascript to do it?


  • Closed Accounts Posts: 512 ✭✭✭beaver


    One reason would be because users can turn it off...

    I guess you could script it server-side to ensure a max length. I'd implement javascript first with that as a backup if javascript is turned off, though.


  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    Yeah just did it on the server side.
    How does one go about getting the length of the text in a textarea in JavaScript?
    I've tried using document.myform.description.value.length
    and document.myform.description.length
    but neither work.
    Anyone know how it's done?


  • Registered Users, Registered Users 2 Posts: 12,309 ✭✭✭✭Bard


    There is no provision for a maximum length in HTML for textareas.

    If you want to implement it on the client, it's probably best done in JavaScript.

    It's a good idea to use ' wrap="virtual" ' in the <textarea> tag, so that the box doesn't end up scrolling to the right when the user is typing.

    It's also a good idea to put a note on the page showing the user what the maximum length should be.


  • Advertisement
  • Closed Accounts Posts: 512 ✭✭✭beaver


    AFAIK the attribute 'wrap' is deprecated.

    EDIT: Also, I doubt I'd bother filling out a form if I had to count how many words I was typing. Just do it server-side. End of complications.


  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    Got it using the above Javascript.
    Go figure??


Advertisement