Regular Expression for multiline validation

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default 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


    Mark Guest

  2. Similar Questions and Discussions

    1. Regular expression validation
      Has anyone figured out a way to use regex in a flash form?? I have tried something like this inside cfformitem tags: function doRegExpVal():void{...
    2. Regular expression help
      Hi, I'm pretty new to regular expressions. Before, I used to write long-winded and buggy segments of code with PHPs string functions to extract...
    3. regular expression - help
      can anyone translate this into plain english? preg_match_all("/(\w+)+/U", $text, $words);
    4. Regular Expression Help please
      All, I have this regular expression which a guy here provided yesterday, this regexp parses an executable name from a log file, however it only...
    5. [PHP] REGULAR EXPRESSION HELP
      John wrote: Your "newline" may be \r\n or \r instead of just \n. -- ---John Holmes... Amazon Wishlist:...
  3. #2

    Default Re: Regular Expression for multiline validation

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

    [url]http://www.aspnet101.com/aspnet101/tips.aspx[/url]



    "Mark" <field027_nospam_@umn.edu> wrote in message news:eMrfWiqWDHA.2880@tk2msftngp13.phx.gbl...
    > 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] Guest

  4. #3

    Default 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:
    [url]www.aboutfortunate.com[/url]

    "Out of chaos comes order."
    Nietzche
    "Mark" <field027_nospam_@umn.edu> wrote in message
    news:eszTJArWDHA.2328@TK2MSFTNGP12.phx.gbl...
    > That looks great for server side validation, but what about client side?
    > Thanks.
    >
    > Mark
    >
    > "Sonali.NET[MVP]" <xb_sonalix@hotmail.com> wrote in message
    > news:ug9Nq9qWDHA.2352@TK2MSFTNGP12.phx.gbl...
    > Take a look @ Tips and Trick Section Recent Validating MaxLength of the
    > TextArea using CustomValidator
    >
    > [url]http://www.aspnet101.com/aspnet101/tips.aspx[/url]
    >
    >
    >
    > "Mark" <field027_nospam_@umn.edu> wrote in message
    > news:eMrfWiqWDHA.2880@tk2msftngp13.phx.gbl...
    > > 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
    > >
    > >
    >
    >

    S. Justin Gengo Guest

  5. #4

    Default Re: Regular Expression for multiline validation

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




    "Mark" <field027_nospam_@umn.edu> wrote in message
    news:eMrfWiqWDHA.2880@tk2msftngp13.phx.gbl...
    > 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
    >
    >

    Eric Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139