0

I'm using this code to send my form using ajaxForm plugin

$('#donations').ajaxForm({
        dataType: 'json',
        beforeSubmit: function(){
            $('#message').html('');
            $('#submit').css('color', 'red').attr("disabled", true);
        },
        success: function(response) {
            if (response.status == 'success'){
                $('#donations').resetForm();
                $('#submit').css('color', 'white').removeAttr("disabled");
                $('#message').html(response.text).delay(5000).fadeOut();
            } else {
                $('#submit').css('color', 'white').removeAttr("disabled");
                $('#message').html(response.text).delay(5000).fadeOut();
            }
        }
    });

The submit button change and the message appear but the form don't reset. What's the problem?

mocheaz
  • 29
  • 7
  • 1
    A similar question to this I believe [link][1] [1]: http://stackoverflow.com/questions/6653556/jquery-javascript-function-to-clear-all-the-fields-of-a-form/ – Valeklosse May 30 '13 at 16:22
  • http://stackoverflow.com/questions/8981064/jquery-validate-resetform-doesnt-reset-the-onfocus-validation – chepe263 May 30 '13 at 16:22

1 Answers1

0

resetForm is an option no function

check this out options-object

Boolean flag indicating whether the form should be reset if the submit is successful

Default value: null

so i think you need to change your code into something like this:

$('#donations').ajaxForm({
    dataType: 'json',
    resetForm: true
    //.........
});
ebram khalil
  • 8,252
  • 7
  • 42
  • 60
  • Thanks for your reply, but i need to clear the form only on certain response, not on success ajax. – mocheaz Jun 03 '13 at 13:41