I took from somewhere the following script which clears all input controls in the ‘mainFrm’ form:
$(':text , textarea , #mainFrm').val('');
$('select option:nth-child(1) , #mainFrm').attr('selected', 'selected');
$(':checkbox , :radio , #mainFrm').removeAttr('checked');
It works really nice, but the problem is that is clears all controls regardless of the fact that some of them may be disabled. I would like to clear only the enabled ones, leaving the disables ones alone. How can I accomplish this? I tried changing the first line to
$(':text , textarea , enabled , #mainFrm').val('');
$(':text:enabled , textarea , #mainFrm').val('');
$(':enabled, text , textarea , #mainFrm').val('');
but none of them worked. Can anyone please help me out with this?
You need to filter your other selectors: