forms - jQuery trigger reset button click -
i need reset radio buttons , checkboxes within form via code when needed.
i using indirect approach, have placed reset button , hidden using css.
<form class="form-horizontal form form-existing" role="form" id="form-existing" action=""> <input type="reset" name="reset-form-new" id="resetformnew" value="" /> <div class="radio"> <label> <input type="radio" name="new-turnover" id="new-turnover" value="€1 000 - €5 000"/> €1 000 - €5 000 </label> </div> <div class="radio"> <label> <input type="radio" name="new-turnover" id="new-turnover" value="€50 000 - €20 0000"/> €50 000 - €20 0000 </label> </div> <div class="checkbox"> <label> <input type="checkbox" name="new-preference" value="mobile phones"> mobile phones </label> </div> <div class="checkbox"> <label> <input type="checkbox" name="new-preference" value="accessories"> accessories </label> </div>
then try click $("#resetformnew").trigger("click");
this resets text boxes not radio buttons , check boxes.
where going wrong?
a form has own reset method can call. rather adding steps hiding reset button, can call like:
$("#form")[0].reset();
Comments
Post a Comment