Hi Thuyai,
Check this example. Now please take its reference and correct your code.
HTML
<div>
Select Fruits<br />
<asp:CheckBoxList ID="chkFruits" runat="server">
<asp:ListItem Text="Mango" />
<asp:ListItem Text="Apple" />
<asp:ListItem Text="Banana" />
<asp:ListItem Text="Pineapple" />
<asp:ListItem Text="Guava" />
<asp:ListItem Text="Grapes" />
<asp:ListItem Text="Papaya" />
<asp:ListItem Text="Other" />
</asp:CheckBoxList>
<asp:CustomValidator ID="CustomValidator1" ErrorMessage="Please select at least one item."
ForeColor="Red" ClientValidationFunction="ValidateCheckBoxList" runat="server" />
<br />
<asp:TextBox ID="txtOtherfruit" Rows="5" TextMode="multiline" runat="server" />
<asp:RequiredFieldValidator ID="rfvOtherFruit" ErrorMessage="Required" ControlToValidate="txtOtherfruit"
Enabled="false" runat="server" ForeColor="Red" />
<br />
<br />
<asp:Button ID="btnSubmit" Text="Submit" runat="server" /><br />
<script type="text/javascript">
function ValidateCheckBoxList(sender, args) {
var checkBoxList = document.getElementById("<%=chkFruits.ClientID %>");
var checkboxes = checkBoxList.getElementsByTagName("input");
var isValid = false;
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].checked) {
if (checkboxes[i].value == 'Other') {
ValidatorEnable(document.getElementById("rfvOtherFruit"), true);
isValid = true;
}
else {
ValidatorEnable(document.getElementById("rfvOtherFruit"), false);
}
isValid = true;
}
}
args.IsValid = isValid;
}
</script>
</div>
Screenshot
