Regular Expression for multiline validation

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

    #1

    Regular Expression for multiline validation

    To validate the length of a multiline textbox, I'm told that I have to use a
    regular expression validator. The regular expression below limits it to 25
    characters in length, but if the user enters a hard return, it bombs
    regardless of length. How do you allow hard returns in the following
    regular expression? Thanks in advance!

    ^.{0,25}$

    Mark


  • Sonali.NET[MVP]

    #2
    Re: Regular Expression for multiline validation

    Take a look @ Tips and Trick Section Recent Validating MaxLength of the TextArea using CustomValidator





    "Mark" <field027_nospa m_@umn.edu> wrote in message news:eMrfWiqWDH A.2880@tk2msftn gp13.phx.gbl...[color=blue]
    > To validate the length of a multiline textbox, I'm told that I have to use a
    > regular expression validator. The regular expression below limits it to 25
    > characters in length, but if the user enters a hard return, it bombs
    > regardless of length. How do you allow hard returns in the following
    > regular expression? Thanks in advance!
    >
    > ^.{0,25}$
    >
    > Mark
    >
    > [/color]

    Comment

    • S. Justin Gengo

      #3
      Re: Regular Expression for multiline validation

      Mark,

      Sorry, I took that expression from another forum's post. I had never
      actually tested it myself. My bad. I just played around a bit. Try this
      instead: ^[\s\S]{0,10}$

      --
      S. Justin Gengo, MCP
      Web Developer

      Free code library at:
      www.aboutfortunate.com

      "Out of chaos comes order."
      Nietzche
      "Mark" <field027_nospa m_@umn.edu> wrote in message
      news:eszTJArWDH A.2328@TK2MSFTN GP12.phx.gbl...[color=blue]
      > That looks great for server side validation, but what about client side?
      > Thanks.
      >
      > Mark
      >
      > "Sonali.NET[MVP]" <xb_sonalix@hot mail.com> wrote in message
      > news:ug9Nq9qWDH A.2352@TK2MSFTN GP12.phx.gbl...
      > Take a look @ Tips and Trick Section Recent Validating MaxLength of the
      > TextArea using CustomValidator
      >
      > http://www.aspnet101.com/aspnet101/tips.aspx
      >
      >
      >
      > "Mark" <field027_nospa m_@umn.edu> wrote in message
      > news:eMrfWiqWDH A.2880@tk2msftn gp13.phx.gbl...[color=green]
      > > To validate the length of a multiline textbox, I'm told that I have to[/color][/color]
      use[color=blue]
      > a[color=green]
      > > regular expression validator. The regular expression below limits it to[/color][/color]
      25[color=blue][color=green]
      > > characters in length, but if the user enters a hard return, it bombs
      > > regardless of length. How do you allow hard returns in the following
      > > regular expression? Thanks in advance!
      > >
      > > ^.{0,25}$
      > >
      > > Mark
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Eric

        #4
        Re: Regular Expression for multiline validation

        Use a regular expression validator with the expression "(.|\r|\n){0,25 5}"
        replacing the 0 and 255 with the minimum and maximum lengths that you need.




        "Mark" <field027_nospa m_@umn.edu> wrote in message
        news:eMrfWiqWDH A.2880@tk2msftn gp13.phx.gbl...[color=blue]
        > To validate the length of a multiline textbox, I'm told that I have to use[/color]
        a[color=blue]
        > regular expression validator. The regular expression below limits it to 25
        > characters in length, but if the user enters a hard return, it bombs
        > regardless of length. How do you allow hard returns in the following
        > regular expression? Thanks in advance!
        >
        > ^.{0,25}$
        >
        > Mark
        >
        >[/color]


        Comment

        Working...