I have a couple of scenarios I need to create:
1) if a dropdown has a particular value, make a particular textbox a required field.
2) if a particular textbox has data, make another textbox required (if an address field is filled in, require city, state and zip)
I have code to call from a pair of CustomValidators that looks right:
<asp:CustomValidator ID="cvtxt_pat_id" runat="server" OnServerValidate="txt_pat_idValidate" ControlToValidate="txt_pat_id" ErrorMessage="Text must be 8 or more characters." Display="Dynamic"/> protected void txt_pat_idValidate(object sender, ServerValidateEventArgs e) { if (ddl_addl_pat_info.SelectedValue.ToString() == "2") { e.IsValid = (e.Value.Length > 1); } else { e.IsValid = true; } } <asp:CustomValidator ID="cvtxt_pat_id" runat="server" OnServerValidate="addresspartsValidate" ControlToValidate="txt_city" ErrorMessage="Complete address must be entered." Display="Dynamic"/> protected void addresspartsValidate(object sender, ServerValidateEventArgs e) { if (txt_pat_address.Text.Length > 1) { e.IsValid = (e.Value.Length > 1); } else { e.IsValid = true; } } But as I understand it, if the textbox I'm testing is empty, the box never validates, so these don't fire if they're blank, which kind of makes it hard to check for a required field. So...thoughts?
Also, I'm getting conflicting stories as to whether or not I need to have BOTH a client and server version of my test. Perhaps it was required in an older version, and now isn't?