Solved

Validate curreny using ASP.NET validation control

Posted on 2006-11-15
6
289 Views
Last Modified: 2008-02-01
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?
0
Comment
Question by:Mike_Stevens
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 17948113
Try using CompareValidator with Type=Currency and Operator=DataTypeCheck
0
 
LVL 35

Expert Comment

by:YZlat
ID: 17948182
if you have to use currency symbol, then use either RegularExpression or CustomValidator
0
 

Author Comment

by:Mike_Stevens
ID: 17948211
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Expert Comment

by:YZlat
ID: 17948281
try this regular expression:

^(\$)?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$
0
 
LVL 35

Accepted Solution

by:
YZlat earned 500 total points
ID: 17948290
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
 

Author Comment

by:Mike_Stevens
ID: 17948326
That is exactly what i needed.  Thanks
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question