1

I KNOW this question has been asked numerous times as I have used this website's solutions to no avail. I currently have this implementation:

$("input:reset").click(function () {
    $('#answer_2').html('License number is not long enough');
    $('#answer_1').html('');
    $('#data_entry').each (function(){
        this.reset();
    });
});

I know the selector is correct as the two html changes (I put them in to confirm I was selector for the reset button click correctly) occur as they should.

Here is my form declaration:

<form name="data_entry" id="data_entry" method="post" action="">

The problem is I keep getting the error that there is no 'reset' function and the form is never cleared. This is my most recent attempt at following answers to this problem on stackoverflow site. Please help.

Henry Geiter
  • 103
  • 1
  • 10

2 Answers2

2

Why reset when you want to clear/empty?

this.empty();

might do the trick?

Daryl Gill
  • 5,464
  • 9
  • 36
  • 69
1

Your each is wrong and it's unnecessary.

$('#data_entry').get(0).reset();

This should work because you got the right element but $() returns a jQuery object, not a DOM element. get will grab your DOM element and then you can use reset() (which is not a jQuery function)

Machavity
  • 30,841
  • 27
  • 92
  • 100