textarea length setting

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bill

    textarea length setting

    Hi.

    Is there any way to set a textarea to a limited number of characters, like
    the text element?

    PS I'm not talking about line width and num lines, which I know you can set.

    Thanks.


  • Thomas 'PointedEars' Lahn

    #2
    Re: textarea length setting

    Bill wrote:
    [color=blue]
    > Is there any way to set a textarea to a limited number of characters, like
    > the text element?[/color]

    <!-- Allows no more than 10 characters -->
    <textarea ... onkeyup="if (this.value.len gth > 10) this.value =
    this.value.subs tring(0, 10);">...</textarea>

    This works in IE 6 SP-1 and Mozilla/5.0 rv:1.5 on Win2k.
    But since client-side scripting can be disabled or (partly)
    not supported, server-side form checking is also required.
    [color=blue]
    > PS I'm not talking about line width and num lines, which I know you can set.[/color]

    How do get that idea? Line width and number of lines is exactly what you
    cannot restrict in contrast to the length of the value. You can merely
    define how long a line *should* be *displayed* before the text is *wrapped*
    and how many wrapped lines *should* be *displayed* simultaneously without
    *scrolling*.


    PointedEars

    Comment

    • Bill

      #3
      Re: textarea length setting


      "Thomas 'PointedEars' Lahn" <PointedEars@we b.de> wrote in message
      news:3F9959E5.7 0508@PointedEar s.de...[color=blue]
      > Bill wrote:
      >[color=green]
      > > Is there any way to set a textarea to a limited number of characters,[/color][/color]
      like[color=blue][color=green]
      > > the text element?[/color]
      >
      > <!-- Allows no more than 10 characters -->
      > <textarea ... onkeyup="if (this.value.len gth > 10) this.value =
      > this.value.subs tring(0, 10);">...</textarea>
      >
      > This works in IE 6 SP-1 and Mozilla/5.0 rv:1.5 on Win2k.
      > But since client-side scripting can be disabled or (partly)
      > not supported, server-side form checking is also required.[/color]

      Thanks.
      [color=blue]
      >[color=green]
      > > PS I'm not talking about line width and num lines, which I know you can[/color][/color]
      set.[color=blue]
      >
      > How do get that idea? Line width and number of lines is exactly what you
      > cannot restrict in contrast to the length of the value. You can merely
      > define how long a line *should* be *displayed* before the text is[/color]
      *wrapped*[color=blue]
      > and how many wrapped lines *should* be *displayed* simultaneously without
      > *scrolling*.[/color]

      Didn't know that either. Thanks again Thomas...




      Comment

      Working...