Dropdownlist validate


function OnSelectedIndexChange()
{
   var s = document.getElementById('<%=ddlPosition.ClientID%>');
   if (s.value == '0')     // or  if (s.options[s.selectedIndex].text=='select')
   {
      alert("Please select the different option.");
      return false;
   }
   else
      return true;
}

<asp:DropDownList ID="ddlPosition" runat="server" onchange="OnSelectedIndexChange();"/>

Comments