Sunday, 9 January 2022

Enable Disable Control in jQuery | CheckBox Check/UnCheck Enable Disable Control Using jQuery

1/09/2022 - By Pranav Singh 0

 In this article i will show you how you can enable or disable dropdown / Textbox / Button / ListBox / TextArea / CheckBox / RadioButton  / File on  check and uncheck of checkbox control using jQuery. You can user it in Asp.Net / MVC / Asp.Net Core application. 


Here is the code to make the control enable and disable.  Suppose we have a checkbox control and want the make enable disable the dropdown list control in check and uncheck of checkbox.


<input type="checkbox" id="chkIsclient" class="form-control" onclick="javascript: IsClient();" />

<div class="form-group">

    <label for="statu">Select Client</label>

    <select class="form-control form-control-sm" id="ClientMasterId" disabled="disabled">

        <option value="">Select Client</option>

        <option value="1">Bajaj Automobile1</option>

        <option value="2">Bajaj Automobile2</option>

    </select>

</div>


In above code we will create a JavaScript function on click on checkbox. I have also defined a dropdown control. and set attribute disabled="disabled", this will make the control display in disable disabled mode. Now here is our jQuery code.  

var IsClient = function () {

        if ($("#chkIsclient").prop('checked')) {

            $("#ClientMasterId").removeAttr('disabled');

        } else {

            $("#ClientMasterId").attr('disabled', 'disabled');

        }

    }


Now we have done run the code and check the output. 

Enable Disable Control in jQuery | CheckBox Check/UnCheck Enable Disable Control Using jQuery

Now when we check the checkbox we will get enabled dropdown list box.

Enable Disable Control in jQuery | CheckBox Check/UnCheck Enable Disable Control Using jQuery

About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top