Limit entry into TextArea

Discussion in 'Javascript' started by JohnSouth, Jan 31, 2006.

  1. JohnSouth

    JohnSouth Guest

    Hi

    In a TextBox I can set a maximum size for the entry.
    Is there a way of limiting the number of characters being entered into
    a TextArea control?

    John South
    www.wherecanwego.com
     
    JohnSouth, Jan 31, 2006
    #1
    1. Advertising

  2. JohnSouth

    impaler Guest

    JohnSouth wrote:
    > Hi
    >
    > In a TextBox I can set a maximum size for the entry.
    > Is there a way of limiting the number of characters being entered into
    > a TextArea control?
    >
    > John South
    > www.wherecanwego.com


    <textarea onkeypress="if (this.value.length > 200) this.value =
    this.value.substr(0, 200);">
    </textarea>

    do this on onblur too, to avoid copy paste and if there are other
    scenarios to put more too.
     
    impaler, Jan 31, 2006
    #2
    1. Advertising

  3. impaler wrote:

    > JohnSouth wrote:
    >> In a TextBox I can set a maximum size for the entry.
    >> Is there a way of limiting the number of characters being entered into
    >> a TextArea control?
    >>
    >> John South
    >> www.wherecanwego.com

    >
    > <textarea onkeypress="if (this.value.length > 200) this.value =
    > this.value.substr(0, 200);">
    > </textarea>
    >
    > do this on onblur too, to avoid copy paste and if there are other
    > scenarios to put more too.


    Why not limit length of input in the first place?

    <textarea onkeypress="return (this.value.length <= 200);"></textarea>

    where the parens are not necessary. This should be extended to tell
    the user why the number of characters is limited.


    PointedEars
     
    Thomas 'PointedEars' Lahn, Jan 31, 2006
    #3
  4. JohnSouth

    impaler Guest


    > Why not limit length of input in the first place?
    >


    It's a javascript topic so I thought he wants a javascript solution :)
     
    impaler, Feb 1, 2006
    #4
  5. impaler wrote:

    >
    >> Why not limit length of input in the first place?
    >>

    >
    > It's a javascript topic so I thought he wants a javascript solution :)


    You are talking nonsense. Mine *is* a JavaScript solution as well, which,
    in contrast to yours, limits the length of input on the first place rather
    than correcting the value afterwards. And any solution for this problem
    cannot qualify as a JavaScript solution alone, because the DOM is involved
    always.

    Learn to quote.


    PointedEars
     
    Thomas 'PointedEars' Lahn, Feb 1, 2006
    #5
  6. JohnSouth

    JohnSouth Guest

    Thanks to All. It's clear to me now, and it makes a big improvement to
    the entry screen.
    Cheers

    John South
    www.wherecanwego.com

    Thomas 'PointedEars' Lahn wrote:
    > impaler wrote:
    >
    > >
    > >> Why not limit length of input in the first place?
    > >>

    > >
    > > It's a javascript topic so I thought he wants a javascript solution :)

    >
    > You are talking nonsense. Mine *is* a JavaScript solution as well, which,
    > in contrast to yours, limits the length of input on the first place rather
    > than correcting the value afterwards. And any solution for this problem
    > cannot qualify as a JavaScript solution alone, because the DOM is involved
    > always.
    >
    > Learn to quote.
    >
    >
    > PointedEars
     
    JohnSouth, Feb 4, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AtomicBob
    Replies:
    14
    Views:
    952
    Toby Inkster
    May 2, 2006
  2. Iain Wilson

    Clear A Textbox/TextArea On-Entry

    Iain Wilson, Feb 28, 2008, in forum: ASP .Net
    Replies:
    3
    Views:
    1,579
    Iain Wilson
    Feb 28, 2008
  3. Mike Owen

    Allowing entry of a Carriage Return during data entry

    Mike Owen, Jul 27, 2006, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    771
    Alessandro Zifiglio
    Jul 27, 2006
  4. Augustus
    Replies:
    1
    Views:
    384
    Ken Schaefer
    Sep 10, 2003
  5. Noozer
    Replies:
    2
    Views:
    290
    Dr John Stockton
    Aug 1, 2005
Loading...

Share This Page