Validate curreny using ASP.NET validation control

I am trying to validate when a user enters a currency value.  I am using a range validator.  I have set the minimum value and the maximum values for the validator.  The problem that i am having is when the user includes a dollar sign ($) it will not validate becuase the $ is not valid.  How can i validate a currency entry even if the user includes the dollar sign?
Mike_StevensAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
YZlatConnect With a Mentor Commented:
you'll need something like that:

<asp:RegularExpressionValidator id="RegularExpressionValidator1" runat="server" ErrorMessage="Invalid currency!" ControlToValidate="your control name here" ValidationExpression="^(\$)?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$"></asp:RegularExpressionValidator>
0
 
YZlatCommented:
Try using CompareValidator with Type=Currency and Operator=DataTypeCheck
0
 
YZlatCommented:
if you have to use currency symbol, then use either RegularExpression or CustomValidator
0
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

 
Mike_StevensAuthor Commented:
That is what i am asking....i need to validate the entry if the user does or does not enter the dollar symbol.  The compare method you reccomended does not work.  
0
 
YZlatCommented:
try this regular expression:

^(\$)?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$
0
 
Mike_StevensAuthor Commented:
That is exactly what i needed.  Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.