Avatar of Wigging
Wigging
Flag for United States of America asked on

validate currency

 If CityName.Text > coprice.Text Then

cityname= 5
coprice=25.99

i keep getting error that CityName.Text  is greater but it isnt????
ASP.NET

Avatar of undefined
Last Comment
Alfred A.

8/22/2022 - Mon
Randy Downs

plusone3055

if  Cstr(CityName.Text) > cstr(coprice.Text) then  
Randy Downs

something like this maybe

<asp:TextBox id="TextBox1" runat="server" />
<asp:RequiredFieldValidator id="RVF1" runat="server" ControlToValidate="TextBox1"  
   ErrorMessage="Required" Display="Dynamic" />
<asp:CompareValidator id="CheckFormat1" runat="server" ControlToValidate="TextBox1" Operator="DataTypeCheck"  
   Type="Currency"  Display="Dynamic" ErrorMessage="Illegal format for currency" />
<asp:RangeValidator id="RangeCheck1" runat="server" ControlToValidate="TextBox1"
   Type="Currency" Minimum="1.00" Maximum="999.99" ErrorMessage="Out of range" Display="Dynamic" />
Your help has saved me hundreds of hours of internet surfing.
fblack61
Rick

Because you want to compare numbers, not text, use this:

   if cdbl(CityName.Text) > cdbl(coprice) then

Rick

Forgot the text attribute:

   if cdbl(CityName.Text) > cdbl(coprice.text) then
ASKER CERTIFIED SOLUTION
Alfred A.

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.