You can set Display Dynamic for ValidationControl.
HTML:
<form id="form1" runat="server">
<div>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
Education
</td>
<td>
<asp:DropDownList ID="ddlEducation" runat="server">
<asp:ListItem Text="PleaseSelect" Value="0" />
<asp:ListItem Text="BE" Value="1" />
<asp:ListItem Text="BSCIT" Value="2" />
<asp:ListItem Text="Diploma" Value="3" />
<asp:ListItem Text="HSC" Value="4" />
</asp:DropDownList>
<asp:CustomValidator ID="cvEducation" runat="server" Display="Dynamic" ForeColor="Red"
ErrorMessage="*" ControlToValidate="ddlEducation" ClientValidationFunction="EducationCheck"></asp:CustomValidator>
</td>
</tr>
<tr>
<td>
Board
</td>
<td>
<asp:DropDownList ID="ddlBoard" runat="server">
<asp:ListItem Text="PleaseSelect" Value="0" />
<asp:ListItem Text="MSBTE" Value="1" />
<asp:ListItem Text="MUMBAI" Value="2" />
<asp:ListItem Text="DELHI" Value="3" />
<asp:ListItem Text="VTU" Value="4" />
</asp:DropDownList>
<asp:CustomValidator ID="CustomValidator1" runat="server" Display="Dynamic" ForeColor="Red"
ErrorMessage="*" ControlToValidate="ddlBoard" ClientValidationFunction="BoardCheck"></asp:CustomValidator>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Button Text="Save" runat="server" />
</td>
</tr>
</table>
</div>
</form>
Java Script:
<script type="text/javascript">
function EducationCheck(source, args) {
var ddlEducation = document.getElementById("<%=ddlEducation.ClientID%>");
var country = ddlEducation.options[ddlEducation.selectedIndex].value;
if (country == "0") {
args.IsValid = false;
}
else {
args.IsValid = true;
}
}
function BoardCheck(source, args) {
var ddlEducation = document.getElementById("<%=ddlBoard.ClientID%>");
var country = ddlEducation.options[ddlEducation.selectedIndex].value;
if (country == "0") {
args.IsValid = false;
}
else {
args.IsValid = true;
}
}
</script>
Thank You.