Limiting size of Multi-line text box

Discussion in 'ASP .Net Web Controls' started by paul reed, Dec 1, 2003.

  1. paul reed

    paul reed Guest

    Hello,

    I have a multi-line text box. The MaxLength property only works for
    single-line text boxes. What are my options to limit the number of
    characters entered to let's say 180? I can of course check the length on
    postback I guess. I could also use jscript on the client?

    What is the preferred approach?

    Paul
    paul reed, Dec 1, 2003
    #1
    1. Advertising

  2. paul reed

    Sink Guest

    You could us a validator control.
    Probably a RegularExpressionValidator with
    EnableClientScript = true,
    ControlToValidate = <your textbox control>

    this would automatically create a javascript
    routine to check the clientside and another check on the
    server side, be sure to check Page.IsValid on the server
    side.

    Both are really necessary 'cause it is rather easy to
    work around clientside javascript for a hacker.

    Example Regular expression:

    ^[^<>]{5,180}

    This would check for script injection and set min length
    to 5 and max length to 180.
    Regards
    Sink
    >-----Original Message-----
    >Hello,
    >
    >I have a multi-line text box. The MaxLength property only

    works for
    >single-line text boxes. What are my options to limit the

    number of
    >characters entered to let's say 180? I can of course

    check the length on
    >postback I guess. I could also use jscript on the client?
    >
    >What is the preferred approach?
    >
    >Paul
    >
    >
    >.
    >
    Sink, Dec 1, 2003
    #2
    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. Kieran Breen

    multi line text box max length

    Kieran Breen, Feb 15, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    10,693
    nataraj_mca
    Jun 14, 2007
  2. Gnarlodious
    Replies:
    4
    Views:
    17,588
    elizas
    May 5, 2010
  3. Replies:
    0
    Views:
    1,051
  4. Franklin
    Replies:
    2
    Views:
    697
    William J. Familia
    Feb 20, 2009
  5. Rogue Chameleon

    Limiting characters in a text box

    Rogue Chameleon, Nov 18, 2004, in forum: Javascript
    Replies:
    10
    Views:
    159
    Rob B
    Nov 23, 2004
Loading...

Share This Page