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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Dec 2006
    Posts
    417
    Thanks
    168
    Thanked 1 Time in 1 Post

    long strings of user input breaks formatting

    I have TEXTAREA input fields

    Users can submit data.. if a long string is entered without spaces (like a URL) the string goes beyond the width of the div container.

    what is a stylistically pleasing way to prevent this from occurring?


    I assume exploding each word with a space and then counting the length of each word in the data. if length of a word is larger than a certain integer then add ' ...' a space followed by 3 periods

    Is there another way of doing this than the way I described above?

  • #2
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    If you don't want to wrap URLs you could do something like this:
    PHP Code:
    $str 'http://www.loooooooooooooooongurl.com/';
    echo 
    strlen($str) > 20 substr($str020) . '...' $str
    Where "20" is the string length limit. You could make it a variable if you want to be able to only change it in once place.


  •  

    Posting Permissions

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