1

I have a search form which have two buttons: the search button and the reset button. the reset button works before going to the next page but returning to the page (using the back button), the reset button no longer works. The function for the reset button is below. Can you help me to solve this issue. Thanks.

$(function() {
    $("###frmName#-btnReset").click(function(event) {

        $("form[name='#frmName#']")[0].reset();

    });
});
  • Actually why do you need here event.preventDefault(); event.stopPropagation(); –  Aug 01 '16 at 06:43
  • Hello, if I remove these two lines of code, it still not working. I put an alert in the function, it's working but i don't why the .reset() function is not working. – user3910487 Aug 01 '16 at 07:04
  • Try to use type="reset" in your html instead reset form using jquery – Shrikant D Aug 01 '16 at 07:25
  • ok, i tried the type='reset' in my html, it's still not working. However, it works on first loading of the page but when going back to the page again (clicking on the back button), it no longer works. – user3910487 Aug 01 '16 at 08:02
  • Pretty sure it's not symantically correct to have number signs `#` in an `id` or `name` attribute. See http://stackoverflow.com/questions/1077084/what-characters-are-allowed-in-dom-ids – War10ck Aug 01 '16 at 14:06
  • hello, the sign # is because i'm using cold fusion. it works at first load of the page – user3910487 Aug 01 '16 at 16:21

0 Answers0