Skip to content
Advertisement

Validate ASP.NET Dropdownlist Control with bootstrap Validator

I have a asp dropdownlist <asp:DropDownList ID="ddIndProvince" data-style="btn-default" CssClass="form-control input" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddIndProvince_SelectedIndexChanged" TabIndex="8"></asp:DropDownList> On Page load event I inserted “–Select–” item at index 0. Now I am facing problem while I am validating it with bootstrap validator. Its returning valid for “–Select–” item. like below image. enter image description here

How I can validate this.Below us my current script

JavaScript

Advertisement

Answer

bootstrapValidator is validating the value attribute of the <option> tag in your html markup.

Your javascript code is correct. What you need to do is make sure, the value attribute is empty:

Change your markup from:

JavaScript

To:

JavaScript

Do this in your Page_Load method:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement