How can i check if a text in of one textbox is equal to or greater than the text in another textbox ?
I have tried range validator and compare validator but cant get anything to work.
How can i check if a text in of one textbox is equal to or greater than the text in another textbox ?
I have tried range validator and compare validator but cant get anything to work.
C#:
double a = Convert.ToDouble(TextBox1.Text);
double b = Convert.ToDouble(TextBox2.Text);
if (a == b)
{
// Do things
}
ASP: https://forums.asp.net/t/1793666.aspx?Compare+two+numeric+text+box
You need to use CompareValidator
, and fill the ControlToValidate
and ControlToCompare
with your Textboxes IDs as below :
<asp:CompareValidator
ID="cvEndYear2" Operator="GreaterThanEqual" runat="server"
ValidationGroup="Validate" ControlToValidate="YourFirstTextBoxID"
ControlToCompare="YourSecondTextBoxID" ErrorMessage="" SetFocusOnError="true">
</asp:CompareValidator>
if (double.Parse(TextBox1.Text) > double.Parse(TextBox2.Text))
{
// 1 greater than 2
}
else
{
// 1 less than or equal to 2
}