The issue I have is that I need a way to compare the values from 4 textboxes input by user with another 6 textboxes input by user. If they dont match then fire validation to stop progress. I use a label called 'lblH1' to show they need to match textboxes. Is it possible to use compare validator or ranger validator controls to do this?
h1_total = Convert.ToInt32(txtKS_1.Text) + Convert.ToInt32(txtKS_2.Text) +
Convert.ToInt32(txtKS_3.Text) + Convert.ToInt32(txtKS_4.Text);
H2A_total = Convert.ToInt32(txtH2A_1.Text) + Convert.ToInt32(txtH2A_2.Text) +
Convert.ToInt32(txtH2A_3.Text) + Convert.ToInt32(txtH2A_4.Text) +
Convert.ToInt32(txtH2A_5.Text) + Convert.ToInt32(txtH2A_6.Text);
if (h1_total == H2A_total)
{
//save
}
else
{
lblH1.Visible = true;
lblH1.Text= "Values must match";
}
You can try
CustomValidator
for this, like shown belowThings to be noted:
I have used
ClientIDMode="Static"
just for the sake of making code compact, please ignore it if you can and usedocument.getElementById('<%= txtH2A_6.ClientID %>')
etc.