First, you need to insert beside the combo box a custom
validator like this,
<asp:CustomValidator ID="cv" runat="server" ControlToValidate="cmb" Text="*" ForeColor="Red" ValidateEmptyText="true" ClientValidationFunction="CustomValidator" Display="Dynamic" ErrorMessage="combo box is required!" CssClass="validator"
ValidationGroup="valGrp"></asp:CustomValidator>
If
your combo box default selected value is an empty string then you need to add a
function inside a <script type="text/javascript">
like this,
function
CustomValidator(s, e) {
if
($find(s.controltovalidate)._textBoxControl.value == "")
{
e.IsValid = false;
}
}
If
your combo box default value of “Please select” then you need to add a function
inside a <script type="text/javascript”>
like this,
function
CustomValidator(s, e) {
if
($find(s.controltovalidate)._textBoxControl.value == "Please
select") {
e.IsValid = false;
}
}
References used:
No comments:
Post a Comment