How to get the parsley.js reset() method to reset the form

M Khan picture M Khan · Apr 11, 2014 · Viewed 18.3k times · Source

I am having hard time figuring out to get the parsley.js 2.0 reset() method to fire upon clicking the reset button. This is my reset button:

<input type="reset" id="resetForm" value="Reset" />

I have setup a click event:

$('#resetForm').click(function () {
    $('#myForm').parsley('reset');
});

Obviously this doesn't work. And I can't figure out how to call the reset() method. I understand that it is part of the ParsleyUI but how do I get it to fire ?

I have tried to access a bunch of different ways but obviously my lack of significant JS/jQuery knowledge is getting the best of me.

Any help will be appreciated.

Thank You.

Answer

Lu&#237;s Cruz picture Luís Cruz · Apr 26, 2014

Instead of using

$('#myForm').parsley('reset');

Try using

$('#myForm').parsley().reset();

Assuming your form has the id "myForm" and you have no JS errors, this should work.