My Scenario is , I have a RadList box with Checkboxes="true" property and a button . If user click on button with out check any item from the radList box then I have to show an error message. For this I used Custom Validator function and Specified Same validator Group name for CustomValidator and Button. But this Custom Validator function is executing by check/Uncheck the Items in the RadList Box.
My Code Snippet is :-
function Is_Event_selected(sender, args) {
debugger;
var lstbox = $find("lstEvents");
var chkedItems_Count = lstbox.get_checkedItems().length;
args.IsValid = chkedItems_Count > 0;
}
<div>
<asp:CustomValidator ID="CV_lstEvents" runat="server" ValidateEmptyText="true" ClientValidationFunction="Is_Event_selected"
ControlToValidate="lstEvents" ErrorMessage="please Select Items(s)" ValidationGroup="Event_Group_Validation">
</asp:CustomValidator>
<telerik:RadListBox ID="lstEvents" runat="server" Width="100%" MaxHeight="225px"
CheckBoxes="true" AutoPostBack="false" EmptyMessage="Select Event" CausesValidation="false" >
<Items>
<telerik:RadListBoxItem Text="Ajax Controls" Value="0" />
<telerik:RadListBoxItem Text="BI Controls" Value="1" />
<telerik:RadListBoxItem Text="SilverLight" Value="2" />
<telerik:RadListBoxItem Text="KenDo UI" Value="3" />
</Items>
</telerik:RadListBox>
<asp:Button ID="btn" runat="server" ValidationGroup="Event_Group_Validation" />
</div>