<asp:DropDownList ID="ddl" runat="server" ClientIDMode="Static" OnSelectedIndexChanged="ddl_SelectedIndexChanged"></asp:DropDownList> <asp:Label ID="label" runat="server" ClientIDMode="Static" CssClass="field" Width="150px"></asp:Label> <script type="text/javascript"> $(function () { $("#ddl").change(function (e) { var itemExists = false; var txt = $("#label").val(); e.preventDefault(); $("#ddl option").each(function () { if ($(this).text() == $.trim(txt)) { itemExists = true; alert('Item already exists'); } }); }); }); </script>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)