Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regular Expression Validator

Status
Not open for further replies.

primagic

IS-IT--Management
Jul 24, 2008
476
0
0
GB
I have the following regular expression validator on textboxes where users enter in a numeric amount that is to be added to an sql database with decimal datatype.

Code:
^\d+(\.\d\d)?$

If the field is left blank it comes up with input string was not in correct format. Also even if I type in 50 or 50.00 it comes up with the same error.

Any ideas

Thanks
 
You have a couple of options here.
I would use a CompareValidator. Then set the Operator property to DataTypeCheck and the Type property to Double.
If you want to use a RegularExressionValidator, remember, the expressions can become complicated. I don't use regular expressions often enough to remember how to do them off the top of my head. So, what I use is a tool you can download called Espresso. It helps you build and test regular expressions. It is very flexible and has many standard regular expressions built right in, so you may find what you need there. Check it out, you can download it here:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top