I am facing an issue with my aspx page and CS code. I have implemented two radio buttons, YES and NO, where checking YES makes a textbox visible and checking NO hides it. The problem arises when the textbox is left empty - the validation error is not triggered upon checking the radio button. I have tried to handle this validation through the CS code. Please refer to the JS fiddle provided below for more details.
JS fiddle: - "http://jsfiddle.net/BaxJe/"
Additionally, you can review the button click code snippet for reference:
protected void btnSubmit_Click(object sender, EventArgs e)
{
SendMail();
if (Page.IsValid)
{
if (radiobtnIsCustomer.Checked && txt_custId.Text == string.Empty)
{
div_errorMsg.InnerText = "Please enter your Customer Id.";
return;
}
}
if (!CaptchaControl1.IsValid)
{
lblCaptchaError.Text = "Invalid Captcha";
}
Response.Redirect("ThankYou_AgriBusiness.html");
Customer newCustomer = new Customer();
newCustomer.IsExistingCustomer = radiobtnIsCustomer.Checked;
newCustomer.ExistingCustomerId = txt_custId.Text;
}
I would appreciate any insights on where I might be going wrong, so I can resolve the issue with the validation message. Thank you.
Thanks