How to validate numeric string

Discussion in 'ASP .Net Web Controls' started by Peter Afonin, Nov 4, 2004.

  1. Peter Afonin

    Peter Afonin Guest

    Hello,

    Should be a pretty simple question:

    I need to validate a string. It must be numeric and contain exactly 12
    characters. I know how to do it in code, but I'd like to use a validation
    control. Should I use a Regular expression validator? What expression should
    I use? I checked http://www.regxlib.com, but couldn't find exactly what I
    need.

    I would appreciate your help.

    Thank you,

    --
    Peter Afonin
     
    Peter Afonin, Nov 4, 2004
    #1
    1. Advertising

  2. Peter Afonin

    Scott M. Guest

    Use a RegularExpression Validator. You didn't tell us what your numeric
    format is though, so we can't suggest a pattern.


    "Peter Afonin" <> wrote in message
    news:...
    > Hello,
    >
    > Should be a pretty simple question:
    >
    > I need to validate a string. It must be numeric and contain exactly 12
    > characters. I know how to do it in code, but I'd like to use a validation
    > control. Should I use a Regular expression validator? What expression
    > should
    > I use? I checked http://www.regxlib.com, but couldn't find exactly what I
    > need.
    >
    > I would appreciate your help.
    >
    > Thank you,
    >
    > --
    > Peter Afonin
    >
    >
     
    Scott M., Nov 4, 2004
    #2
    1. Advertising

  3. Peter Afonin

    Peter Afonin Guest

    Thank you, Scott.

    Any numbers, exactly 12 digits: 273861129372, for example. No other
    characters, like "." or "," or "-".

    Peter

    "Scott M." <> wrote in message
    news:...
    > Use a RegularExpression Validator. You didn't tell us what your numeric
    > format is though, so we can't suggest a pattern.
    >
    >
    >
    > news:...
    > > Hello,
    > >
    > > Should be a pretty simple question:
    > >
    > > I need to validate a string. It must be numeric and contain exactly 12
    > > characters. I know how to do it in code, but I'd like to use a

    validation
    > > control. Should I use a Regular expression validator? What expression
    > > should
    > > I use? I checked http://www.regxlib.com, but couldn't find exactly what

    I
    > > need.
    > >
    > > I would appreciate your help.
    > >
    > > Thank you,
    > >
    > > --
    > > Peter Afonin
    > >
    > >

    >
    >
     
    Peter Afonin, Nov 4, 2004
    #3
  4. Peter Afonin

    Scott M. Guest

    \d{12}



    "Peter Afonin" <> wrote in message
    news:...
    > Thank you, Scott.
    >
    > Any numbers, exactly 12 digits: 273861129372, for example. No other
    > characters, like "." or "," or "-".
    >
    > Peter
    >
    > "Scott M." <> wrote in message
    > news:...
    >> Use a RegularExpression Validator. You didn't tell us what your numeric
    >> format is though, so we can't suggest a pattern.
    >>
    >>
    >>
    >> news:...
    >> > Hello,
    >> >
    >> > Should be a pretty simple question:
    >> >
    >> > I need to validate a string. It must be numeric and contain exactly 12
    >> > characters. I know how to do it in code, but I'd like to use a

    > validation
    >> > control. Should I use a Regular expression validator? What expression
    >> > should
    >> > I use? I checked http://www.regxlib.com, but couldn't find exactly what

    > I
    >> > need.
    >> >
    >> > I would appreciate your help.
    >> >
    >> > Thank you,
    >> >
    >> > --
    >> > Peter Afonin
    >> >
    >> >

    >>
    >>

    >
    >
     
    Scott M., Nov 4, 2004
    #4
  5. Also remember that the RegularExpressionValidator does not *require*
    that a value be present, so if you want to force this you must, in
    addition, use a RequiredFieldValidator.

    Scott M. wrote:
    > \d{12}
    >
    >
    >
    > "Peter Afonin" <> wrote in message
    > news:...
    >
    >>Thank you, Scott.
    >>
    >>Any numbers, exactly 12 digits: 273861129372, for example. No other
    >>characters, like "." or "," or "-".
    >>
    >>Peter
    >>
    >>"Scott M." <> wrote in message
    >>news:...
    >>
    >>>Use a RegularExpression Validator. You didn't tell us what your numeric
    >>>format is though, so we can't suggest a pattern.
    >>>
    >>>
    >>>
    >>>news:...
    >>>
    >>>>Hello,
    >>>>
    >>>>Should be a pretty simple question:
    >>>>
    >>>>I need to validate a string. It must be numeric and contain exactly 12
    >>>>characters. I know how to do it in code, but I'd like to use a

    >>
    >>validation
    >>
    >>>>control. Should I use a Regular expression validator? What expression
    >>>>should
    >>>>I use? I checked http://www.regxlib.com, but couldn't find exactly what

    >>
    >>I
    >>
    >>>>need.
    >>>>
    >>>>I would appreciate your help.
    >>>>
    >>>>Thank you,
    >>>>
    >>>>--
    >>>>Peter Afonin
    >>>>
    >>>>
    >>>
    >>>

    >>

    >
    >



    --

    Scott Mitchell

    http://www.4GuysFromRolla.com

    * When you think ASP.NET, think 4GuysFromRolla.com!
     
    Scott Mitchell [MVP], Nov 4, 2004
    #5
  6. Peter Afonin

    Peter Afonin Guest

    Thank you very much, Scott. I remember this.

    Peter

    "Scott Mitchell [MVP]" <> wrote in message
    news:Lniid.38323$...
    > Also remember that the RegularExpressionValidator does not *require*
    > that a value be present, so if you want to force this you must, in
    > addition, use a RequiredFieldValidator.
    >
    > Scott M. wrote:
    > > \d{12}
    > >
    > >
    > >
    > > "Peter Afonin" <> wrote in message
    > > news:...
    > >
    > >>Thank you, Scott.
    > >>
    > >>Any numbers, exactly 12 digits: 273861129372, for example. No other
    > >>characters, like "." or "," or "-".
    > >>
    > >>Peter
    > >>
    > >>"Scott M." <> wrote in message
    > >>news:...
    > >>
    > >>>Use a RegularExpression Validator. You didn't tell us what your

    numeric
    > >>>format is though, so we can't suggest a pattern.
    > >>>
    > >>>
    > >>>
    > >>>news:...
    > >>>
    > >>>>Hello,
    > >>>>
    > >>>>Should be a pretty simple question:
    > >>>>
    > >>>>I need to validate a string. It must be numeric and contain exactly 12
    > >>>>characters. I know how to do it in code, but I'd like to use a
    > >>
    > >>validation
    > >>
    > >>>>control. Should I use a Regular expression validator? What expression
    > >>>>should
    > >>>>I use? I checked http://www.regxlib.com, but couldn't find exactly

    what
    > >>
    > >>I
    > >>
    > >>>>need.
    > >>>>
    > >>>>I would appreciate your help.
    > >>>>
    > >>>>Thank you,
    > >>>>
    > >>>>--
    > >>>>Peter Afonin
    > >>>>
    > >>>>
    > >>>
    > >>>
    > >>

    > >
    > >

    >
    >
    > --
    >
    > Scott Mitchell
    >
    > http://www.4GuysFromRolla.com
    >
    > * When you think ASP.NET, think 4GuysFromRolla.com!
     
    Peter Afonin, Nov 4, 2004
    #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. Grey

    validate numeric field

    Grey, Jan 20, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    5,267
    John Timney \(Microsoft MVP\)
    Jan 20, 2004
  2. Peter Afonin

    How to validate numeric string

    Peter Afonin, Nov 4, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    19,238
    Peter Afonin
    Nov 4, 2004
  3. Replies:
    5
    Views:
    954
    X-Centric
    Jun 30, 2005
  4. darrel
    Replies:
    4
    Views:
    841
    darrel
    Jul 19, 2007
  5. jobs

    int to numeric numeric(18,2) ?

    jobs, Jul 21, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    990
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Jul 22, 2007
Loading...

Share This Page