Archive

Archive for November, 2016

Validate Rad ComboBox

November 6, 2016 Leave a comment

Hi all,

Try this example to Validate Rad ComboBox Using ASP.Net Validation Controls


<script type="text/javascript">
 function validateddlType(source, args) {
 args.IsValid = false;
 var combo = $find("<%= ddlType.ClientID %>");
 var text = combo.get_text();
 if (text.length < 1) {
 args.IsValid = false;
 }
 else {
 var node = combo.findItemByText(text);
 if (node) {
 args.IsValid = true;
 }
 else {
 args.IsValid = false;
 }
 }
 }

</script>

<telerik:radcombobox id="ddlType" allowcustomtext="True" runat="server" emptymessage="--- Please Select ---" filter="Contains" skin="Telerik"></telerik:radcombobox>
<asp:RequiredFieldValidator ID="rfvType" ControlToValidate="ddlType" ForeColor="Red" runat="server" Display="Dynamic" ErrorMessage="Value is required" ValidationGroup="A"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="cvType" ClientValidationFunction="validateddlType" ForeColor="Red" ControlToValidate="ddlType" ValidationGroup="A" runat="server" ErrorMessage="Please select a vaild Value"></asp:CustomValidator>

Hope this helps

Good Luck.

Categories: ASP.Net, Javascript