javascript - Disable and reset or empty all inputs -
i'm trying disable every type of input on page , uncheck or empty values, i've written following code:-
function disableall() {                   if ($('#chkloginenabled').is(':checked')) {                       $("input").attr("disabled", false);                   }                   else {                       $("input").attr("disabled", true);                       $("input checkbox").attr('checked') = 'checked';                       $("input textbox").val() = "";                    }                   $("#chkloginenabled").attr("disabled", false);                 } it works disable inputs (and correctly re-enables 1 need),
however, doesn't reset of inputs.
try
function disableall() {     var inputs = $('input');     if ($('#chkloginenabled').is(':checked')) {         inputs.prop('disabled', false);     } else {         inputs.prop('disabled', true);         inputs.filter('[type="checkbox"]').prop('checked', false)         inputs.filter(':text').val('')     }     $('#chkloginenabled').attr('disabled', false); } 
Comments
Post a Comment