Solved

Validate curreny using ASP.NET validation control

Posted on 2006-11-15
6
286 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
  • 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Select2 jquery help 9 89
WIX Redirect 1 48
Example unit tests with AngularJS 3 45
Advice on Xojo as a development tool over VB. 4 55
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

772 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