I'm using customValidator to validate the selected item of the ComboBox. This ComboBox has LoadonDemand enabled. 'validateCombo' code works fine when the selectedIndex is changed. After selecting an item, when a button on the same page is clicked validation doesnt work since there are no items in the ComboBox. How do I make it to work on button click event.
Appreciate your help!!
Appreciate your help!!
<
telerik:RadComboBox
runat
=
"server"
ID
=
"rcbClients"
Height
=
"100px"
EnableLoadOnDemand
=
"true"
ShowMoreResultsBox
=
"true"
EnableVirtualScrolling
=
"true"
AllowCustomText
=
"false"
EmptyMessage
=
"Type lastname ..."
>
<
WebServiceSettings
Path
=
"Service1.svc"
Method
=
"LoadClients"
/>
</
telerik:RadComboBox
>
<
asp:CustomValidator
ID
=
"cvClients"
runat
=
"server"
ClientValidationFunction
=
"validateCombo"
SetFocusOnError
=
"true"
ErrorMessage
=
"Please select a client from Dropdown"
ControlToValidate
=
"rcbClients"
>*
</
asp:CustomValidator
>
function validateCombo(source, args) {
args.IsValid = false;
var combo = $find(source.controltovalidate);
var text = combo.get_text();
var value = combo.get_value();
if (text.length <
1
) {
args.IsValid
=
false
;
}
else
{ var
node
=
combo
.findItemByText(text);
if (node) {
value
=
node
.get_value();
if (value.length > 0) {
args.IsValid = true;
}
}
else {
args.IsValid = false;
}
}
}