Enable Disable Bootstrap SelectPicker DropDownList using jQuery in ASP.Net

Last Reply one month ago By pandeyism

Posted one month ago

How do I disable or remove the validate [required] class from a select picker bootstrap control annex code of how I try to remove it disable it with jquery but it didn't work

$('#<%=ddlMarca.ClientID %>').removeClass("validate[required]");

 

<asp:DropDownList ID="ddlMarca" runat="server" class="form-control selectpicker validate[required]"

 

Posted one month ago
Hi @jmontano,
Please try the following

Enable Disable Bootstrap SelectPicker DropDownList using jQuery in ASP.Net

It might help you.

Cheers Andrea.

Posted one month ago

Hi jmontano,

I checked it's working refer below sample code.

When i remove class then message is now showing.

HTML

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <table border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td>
            </td>
            <td>
                Please fill the following Form
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;
            </td>
            <td>
                &nbsp;
            </td>
        </tr>
        <tr>
            <td>
                City:
            </td>
            <td>
                <asp:DropDownList ID="ddlCities" runat="server" CssClass="form-control selectpicker validate[required]">
                    <asp:ListItem Text="Please Select" Value="" />
                    <asp:ListItem Text="Mumbai" Value="1" />
                    <asp:ListItem Text="Delhi" Value="2" />
                    <asp:ListItem Text="Kolkatta" Value="3" />
                    <asp:ListItem Text="Chennai" Value="4" />
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td>
            </td>
            <td>
                <asp:Button Text="Submit" runat="server" />
            </td>
        </tr>
    </table>
    </form>
    <link href="ValidationEngine.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" />
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script type="text/javascript" src="http://cdn.ucb.org.br/Scripts/formValidator/js/languages/jquery.validationEngine-en.js"
        charset="utf-8"></script>
    <script type="text/javascript" src="http://cdn.ucb.org.br/Scripts/formValidator/js/jquery.validationEngine.js"
        charset="utf-8"></script>
    <script type="text/javascript">
        $(function () {
            $('#<%=ddlCities.ClientID %>').removeClass("validate[required]");   
            $("#form1").validationEngine('attach', { promptPosition: "topRight" });
        });
    </script>
</body>
</html>

Screenshot