Skip to content

Commit 34dc9e8

Browse files
docs(dropdownlist): Add selection validation sample
1 parent 2e0b51a commit 34dc9e8

File tree

1 file changed

+26
-0
lines changed
  • controls/dropdownlist/client-side-programming

1 file changed

+26
-0
lines changed

controls/dropdownlist/client-side-programming/overview.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,32 @@ function onClientDropDownClosing(sender, eventArgs) {
5151

5252
````
5353

54+
## Validating a selection
55+
56+
You can validate the selection of a DropDownList by using the `get_selectedItem()` method:
57+
58+
````JavaScript
59+
60+
function ValidateDropDownList(sender, args) {
61+
var isSelected = false;
62+
var dropDown = $find("<%= RadDropDownList1.ClientID %>");
63+
64+
var selectedItem = dropDown.get_selectedItem();
65+
66+
if (selectedItem) {
67+
var selectedText = selectedItem.get_text();
68+
alert("The selected item's text is " + selectedText);
69+
isSelected = true;
70+
}
71+
else {
72+
alert("Select an item!");
73+
}
74+
75+
return isSelected;
76+
}
77+
78+
````
79+
5480

5581

5682
## Calling a client-side method

0 commit comments

Comments
 (0)