Link to home
Start Free TrialLog in
Avatar of rcowen00
rcowen00Flag for United States of America

asked on

CompareValidator Problem

I'm sure this is a simple mistake but I have a CompareValidator that appears to be comparing the values within the text boxes as String vs Integers.  When I enter 3 in the txtCapacity and 15 in txtMaxCapacity the validation is triggered as an error.  What am I doing wrong.  Thanks!

This is my compare validator
<asp:CompareValidator ID="CompareValidator9" runat="server" 
                         ControlToCompare="txtCapacity" ControlToValidate="txtMaxCapacity" 
                         ErrorMessage="CompareValidator" Operator="GreaterThanEqual" Type="Integer"></asp:CompareValidator>

Open in new window


This is the textboxes
<td>Daily Capacity:*</td>
                            <td>
                                <asp:TextBox runat="server" ID="txtCapacity" MaxLength="3" Columns="10" 
                                    Width="201px" />
                            </td>
                        </tr> 
                          <tr>
                            <td>Max Open Capacity:*</td>
                            <td>
                                <asp:TextBox runat="server" ID="txtMaxCapacity" MaxLength="3" Columns="10" 
                                    Width="201px" />
                            </td>

Open in new window

SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rcowen00

ASKER

Switched it and I get the same thing
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I have tried mixing it up every which way.  It will validate as expected if I enter txtCapacity=4 and txtMaxCapacity=5 but if I enter txtCapacity=4 and txtMaxCapacity=12 then it triggers it as txtMaxCapacity is less than txtCapacity.  I have even tried setting up a custom validator but I get the same results.  Am I inadvertently assigning the field as text and not realizing it???
The problem was caused by 2 validation tags and one was correct and the other incorrect.  Once I removed the incorrect one everything fired correctly