How to validate numeric string

  • Thread starter Thread starter Peter Afonin
  • Start date Start date
P

Peter Afonin

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,
 
Use a RegularExpression Validator. You didn't tell us what your numeric
format is though, so we can't suggest a pattern.
 
Thank you, Scott.

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

Peter

Scott M. said:
Use a RegularExpression Validator. You didn't tell us what your numeric
format is though, so we can't suggest a pattern.
 
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 Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top