Using Zend_Form, it generated a select element where the selection option had an attribute of selected=”selected” instead of just adding “selected” to the element. The form’s reset button no longer works on this element. Because it’s being generated, I can’t simply change how the attribute is specified in the element, so I used some JavaScript to reset all the form elements when a reset button is clicked. If you have multiple forms and multiple reset buttons, then you’ll need to modify this to point at a specific form’s elements rather than all on a page.
$("input:reset").click(function(event) { event.preventDefault(); // Whitelist of fields to minimize unintended side effects. $(':text, :password, :file, SELECT', 'form').val(''); // De-select any checkboxes, radios and drop-down menus $(':input').removeAttr('checked').removeAttr('selected'); $("select").find('option').removeAttr("selected"); }); |