Now in ASP.NET 2.0 and later version you can compaire double values of two textboxes on client side without using javascript code and going to server.
As you an check
12.0 and 12.00 are same double values and 12.0 and 12.001 are different values.
Please note that you can not compaire string values with double compairvalidator. It not not show any validation message.
How to Compaire/Validate Two Double Values in ASP.NET | CompareValidator Example:
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
<body>
<form id="Form1" runat="server">
<h4>
Compare Two Double Values</h4>
Double Value 1:
<asp:TextBox ID="txtDouble1" runat="server" />
<br />
<br />
Double Value 2:
<asp:TextBox ID="txtDouble2" runat="server" />
<br />
<br />
<br />
<asp:Button ID="Button1" Text="Validate" runat="server" />
<br />
<br />
<asp:CompareValidator ID="compair_double_values" ControlToValidate="txtDouble1" ControlToCompare="txtDouble2"
ForeColor="red" Type="Double" Text="Please enter same double values in both textboxes."
runat="server" />
</form>
</body>
</html>
No comments:
Post a Comment