Skip to content Skip to sidebar Skip to footer

Reset Text Fields In Form Fieldset On Bootstrap Tab Press

This question is in context to this.. Html code :

Solution 1:

You need to register the shown.bs.tab event handler once the DOM is ready:

$(function () {
  $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
    $("#xyz > input").val("");
  });      
});

Otherwise the on is trying to bind a handler to an empty list of elements.

Demo

Solution 2:

This will find all inputs within a specific fieldset via fieldset id attribute it will traverse all input fields inside a div or outside and clear them all when you toggle.

 $('a[data-toggle="tabs"]').on('shown.bs.tab', function (e) {
        $("#fieldset_ID").find(':input').each(function() {
            $(this).val('');
        });
    });

Post a Comment for "Reset Text Fields In Form Fieldset On Bootstrap Tab Press"