Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 426
M Khan Avatar asked Apr 11 '14 13:04

M Khan


1 Answers

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.

like image 135
Luís Cruz Avatar answered Oct 20 '22 01:10

Luís Cruz