nitesh garewal

nitesh garewal

  • NA
  • 50
  • 8.1k

how to validate asp:dropdown list using javascript.

Feb 26 2016 6:43 AM
Hey friends,   
             how to change dropdown border color when its initIal value is 00 using jquery
 
 I m using this code but its not working ,,please help
 <script type="text/javascript">
function validate() {
var v = document.getElementById("<%=ddlMDist.SelectedValue%>");
if (v == "00") {
v.style.backgroundColor = "red";
}
 </script>
 
 
 
<asp:UpdatePanel ID="UpdatePanel4" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:DropDownList ID="ddlMDist" runat="server" data-toggle="dropdown" aria-haspopup="true" AutoPostBack="True" TabIndex="6" OnSelectedIndexChanged="ddlMDist_SelectedIndexChanged" onchange="validate();">
<asp:ListItem Value="00">Dist Name</asp:ListItem>
</asp:DropDownList>
 </ContentTemplate>
</asp:UpdatePanel> 
 

Answers (2)