SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Unhappy wrapping text into multiple lines in a text-box

    I was trying to use a textbox as a textarea & by specifying its height, I can make it look like a textarea.
    HTML Code:
      <input type="text" name="myBox" maxlength="70" style="width:50px; height:50px;">
    Now my text-box looks like a textarea but the text continues to be in a single line. I want it to wrap into multiple lines & I can show scrollbars using the overflow property but can't make it wrap in multiple lines.

    The reason I'm trying this is b'coz of the excellent support of the maxlength property of the textbox which doesn't allow any entry if the length of textbox value equals the limit. I know that this can be achieved by using textarea & javascript or serverside validation but I want to use a text-box.

    Can anyone help?
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  2. #2
    The MacGyver of Design bronze trophy Johan Dahlström's Avatar
    Join Date
    Oct 2004
    Location
    Uppsala, Sweden
    Posts
    516
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What you are trying to do here is not possible, and if it was I would'nt support it. Use the inputs and textareas as they're supposed to be used.
    Last edited by Johan Dahlström; Nov 2, 2004 at 14:43.

  3. #3
    Beer Monster -Ox's Avatar
    Join Date
    Apr 2003
    Location
    sowth afreeka
    Posts
    374
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yup, totally, that is why they invented a textarea

    How about applying this little snip of javascript to your text area
    HTML Code:
      <script>
      //Text field counter
      function textCounter(field, countfield, maxlimit)
      {
          if (field.value.length > maxlimit) // if too long...trim it!
              field.value = field.value.substring(0, maxlimit);
          else
              countfield.value = maxlimit - field.value.length;
      }
      
      </script>
      <form>
      
     Characters left:<input readonly="readonly" type="text" name="remLen" size="3" maxlength="3" value="250" style="width:30px" />
      
     <textarea id="sfD" class="frm" name="desc" cols="50" rows="5" onkeydown="textCounter(this.form.desc,this.form.remLen,250);" onkeyup="textCounter(this.form.desc,this.form.remLen,250);">
      </form>
    obviously that is a pretty basic and you will need to style it etc but that is how you can limit a textarea

    please excuse my code its old but the concept's there

    hope that helps

    /Ox
    My postings are a natural product.
    The slight variations in spelling and grammar enhance its
    individual character and beauty and in no way are to be
    considered flaws or defects - http://www.guinnesspig.net

  4. #4
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Ox, if I'd wanted to use JavaScript, I would've done it, its not that hard. Anyways, thanks for your input. But I was looking for some non script validation, that's why I was trying the input text-box.
    I'll look into CSS WiKi & see if there's anything. The darn thing is that there isn't a CSS Manual that one can look up for some property or something. Though DreamWeaverMX 2004 shows the pop-menu for CSS properties but it has nothing that I can use.
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  5. #5
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by asp_funda
    Ox, if I'd wanted to use JavaScript, I would've done it, its not that hard. Anyways, thanks for your input. But I was looking for some non script validation, that's why I was trying the input text-box.
    I'll look into CSS WiKi & see if there's anything. The darn thing is that there isn't a CSS Manual that one can look up for some property or something. Though DreamWeaverMX 2004 shows the pop-menu for CSS properties but it has nothing that I can use.
    This one's not going to happen. Textboxes are for single-line input; textareas are for multiline input.

  6. #6
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,497
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by vgarcia
    This one's not going to happen. Textboxes are for single-line input; textareas are for multiline input.
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!


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
  •