ValidationExpression for a single number

Discussion in 'ASP .Net' started by TD, Nov 28, 2005.

  1. TD

    TD Guest

    Is it possible to validate (or in this case, invalidate) an exact
    number with a RegularExpressionValidator?

    I know that it can be done with javascript but what about regular
    expressions?

    Any 5 digit number between 00000 and 99999 is ok EXCEPT 61280.

    I'm handling the "any 5 digits" portion with this "^\d{5}$" .... Does
    anyone know how to disallow 61280 ?

    Thanks, TD

    <asp:RegularExpressionValidator
    ValidationExpression=""
    Runat="server"
    ControlToValidate="txtsubacct_no"
    ErrorMessage="61280 is not valid"
    Display="Dynamic"
    ID="regexV1">
    </asp:RegularExpressionValidator>
     
    TD, Nov 28, 2005
    #1
    1. Advertising

  2. TD try looking through :-
    http://www.regexlib.com
    It should be able to guide you to match your patter.
    Also see this for reference at :- http://regex.osherove.com/
    Hope that helps
    Patrick

    "TD" <> wrote in message
    news:...
    > Is it possible to validate (or in this case, invalidate) an exact
    > number with a RegularExpressionValidator?
    >
    > I know that it can be done with javascript but what about regular
    > expressions?
    >
    > Any 5 digit number between 00000 and 99999 is ok EXCEPT 61280.
    >
    > I'm handling the "any 5 digits" portion with this "^\d{5}$" .... Does
    > anyone know how to disallow 61280 ?
    >
    > Thanks, TD
    >
    > <asp:RegularExpressionValidator
    > ValidationExpression=""
    > Runat="server"
    > ControlToValidate="txtsubacct_no"
    > ErrorMessage="61280 is not valid"
    > Display="Dynamic"
    > ID="regexV1">
    > </asp:RegularExpressionValidator>
    >
     
    Patrick.O.Ige, Nov 28, 2005
    #2
    1. Advertising

  3. TD

    Peter Blum Guest

    You don't need a regular expression for this.

    Instead, use a RangeValidator with Type=Integer, Min=0 and Max=99999.
    Then add a CompareValidator with ValueToCompare=61280, Type=Integer,
    Operator=NotEquals

    --- Peter Blum
    www.PeterBlum.com
    Email:
    Creator of "Professional Validation And More" at
    http://www.peterblum.com/vam/home.aspx

    "TD" <> wrote in message
    news:...
    > Is it possible to validate (or in this case, invalidate) an exact
    > number with a RegularExpressionValidator?
    >
    > I know that it can be done with javascript but what about regular
    > expressions?
    >
    > Any 5 digit number between 00000 and 99999 is ok EXCEPT 61280.
    >
    > I'm handling the "any 5 digits" portion with this "^\d{5}$" .... Does
    > anyone know how to disallow 61280 ?
    >
    > Thanks, TD
    >
    > <asp:RegularExpressionValidator
    > ValidationExpression=""
    > Runat="server"
    > ControlToValidate="txtsubacct_no"
    > ErrorMessage="61280 is not valid"
    > Display="Dynamic"
    > ID="regexV1">
    > </asp:RegularExpressionValidator>
    >
     
    Peter Blum, Nov 30, 2005
    #3
  4. TD

    TD Guest

    SWEET ! Thanks Peter and Patrick
     
    TD, Nov 30, 2005
    #4
    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. =?Utf-8?B?T2xpdmVyIFNjaHVsemU=?=

    ValidationExpression Syntax

    =?Utf-8?B?T2xpdmVyIFNjaHVsemU=?=, May 12, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,215
    =?Utf-8?B?T2xpdmVyIFNjaHVsemU=?=
    May 12, 2004
  2. =?Utf-8?B?SklNLkgu?=

    ValidationExpression

    =?Utf-8?B?SklNLkgu?=, Nov 17, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    8,246
    Peter Blum
    Nov 18, 2004
  3. Replies:
    3
    Views:
    723
    Rad [Visual C# MVP]
    Nov 17, 2006
  4. Nathan Sokalski
    Replies:
    2
    Views:
    924
    Nathan Sokalski
    Jan 3, 2007
  5. Morten71
    Replies:
    0
    Views:
    655
    Morten71
    Apr 2, 2007
Loading...

Share This Page