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> |
var IsClient = function () { if ($("#chkIsclient").prop('checked')) { $("#ClientMasterId").removeAttr('disabled');
} else { $("#ClientMasterId").attr('disabled', 'disabled');
} } |
0 comments:
Please let me know your view