Mahesh Bodepudi

Mahesh Bodepudi

  • NA
  • 90
  • 56.9k

Disable dropdown controls in MVC4 using JQuery

Aug 22 2016 6:32 AM
Hi,
I have a such scenario where I have to disable some of the controls including the dropdown based on a criteria.
If one of radio button radio is checked and when clicking on submit button the controls should be disabled.Its working for a maximum extent.But some times the page is getting refreshed when clicking on submit button and the controls are appearing and disappearing the page refresh.The page refresh happens only sometimes.
Here is the code for submit button click.
$(#SearchBtn').click(function () {
$('#DivSlNo').hide();
var chkVal = $('input[name=SearchBy]:checked').val();
if (chkVal == 'ShowAll') {
$('#DivSlNo').hide();
$('#DivCriteria').hide();
$('#DivECSId').hide();
}
});
Please help how to overcome this issue?
Tried in the following way to disable the individual elements and div elements.
$('#DivECSId').attr('disabled', 'disabled');
$('#DivECSId').hide();
$('#tdSearchFields :input').attr('disabled', true);
$("#tdSearchFields").find("input,button,textarea,select").attr("disabled", true);
But nothing works for me.

Answers (2)