jquery - Enable all text fields but not the file field -
i'm trying enable every text field call in function, not want enable type="file"
field. happens, type="file"
field being enabled anyway. have missed something?
function disabled_fields(fields, state) { if(state == true) { $(fields).each(function() { $(this).attr('disabled', true); }); } else { if(state == false) { $(fields).each(function() { if($(this).attr('type') != 'file') { $(this).attr('disabled', false); } }); } } }; // runs disabled_fields('input, textarea', false);
you can use .not()
exclude elements,
function disabled_fields(state) { $("input,textarea").not("[type='file']").prop("disabled", state); }
also note that, dont have loop through each elements set disabled property.
Comments
Post a Comment