Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder DR.Wong's Avatar
    Join Date
    Jan 2005
    Posts
    360
    Thanks
    23
    Thanked 1 Time in 1 Post

    Setting Max width of a text area

    Hey everyone...

    This is probably an easy to answer question, but I am at a loss here.

    I have a text area on my site for people to submit comments, and well, it seems some people are entering LOOOONNNNGGG words. Now when they enter these long words, they mess up the alignment on my page when displayed from my database.

    Is there a way to limit the amount of horizontal characters in a text area??

    Thanks a lot!
    -DR.Wong

    Wheres the food at?

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Using just html/css, no, I don't think so. Well, not without cutting off text, anyway. I assume you want a wrapping behavior.

    Using any variety of scripting solutions, yes. You'd have to have some set character count and insert a space or other recognized word delimiter in there if one didn't exist.
    It sounds like the problem is users entering characters in a row, all smushed up, right? No spaces or anything. So, you'd have to make a space either before the data is entered into the DB to begin with, or upon retrieval.

    At least, as far as I know.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,694
    Thanks
    22
    Thanked 1,832 Times in 1,816 Posts
    Hello nikkiH,
    I don't know of any way of making CSS wrap either, but adding overflow: hidden to the CSS of your text area will at least stop it from breaking when someone puts a long word in it, till you figure out how to wrap it.
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #4
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Also, this might have a different answer if the element is a real textarea, like for a form, as opposed to like a div or span.
    I think a textarea form element would wrap regardless, with no issues.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #5
    Regular Coder nolvorite's Avatar
    Join Date
    Dec 2006
    Posts
    176
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Code:
    <!--I am not sure of this, so just recheck.
    <textarea onkeyup="checkmax(100000)">
    </textarea>


  •  

    Posting Permissions

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