Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CompareValidator gets triggered on Page.IsValid but valid client side? 1

Status
Not open for further replies.

modika11

Programmer
Jan 31, 2008
20
Hi All

i have:

Code:
                <label for="txtProductHeight">Height:</label>
                <asp:TextBox ID="txtProductHeight" runat="server" MaxLength="10" Columns="5" CssClass="styled"></asp:TextBox> mm
                <asp:CompareValidator ID="CompareValidator1" runat="server" 
                    ErrorMessage="* Height must be a number" ControlToValidate="txtProductHeight" 
                    Display="Dynamic" Type="Double"></asp:CompareValidator>

when i submit the form (with valid items say 1.1 or 1.0) then the client script validates the text and allows the postback but the server side Page.Isvalid always has a problem with these values and doesnt matter what i put in it always raises the validator???

What have i done wrong?

Rob
 
Add
Code:
Operator="DataTypeCheck"
to your CompareValidator's declaration

Code:
 <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="txtProductHeight" Display="Dynamic"
          ErrorMessage="* Height must be a number" Type="Double" [red]Operator="DataTypeCheck"[/red]></asp:CompareValidator>
 
Hi jbenson001,

Thanks! that did it, sometimes i dont know how i miss these things!

Thanks again!

Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top