Search code examples
jqueryajaxcontact-form

How to reset the New Contact form


I am working on this website, which has a Quick Contact button at the top right. I have generated a contact form which working fine for me so far but the only issue (hopefully!) is RESETTING the form after once successful submission.

After receiving the "Success" message from Ajax I disabled the sent button:

enter image description here

and I add this code to Close button:

$('#close_btn').click(function(){
    $("#myform")[0].reset();
});

to reset the form but if you try the Form you will get the same successful message again. How can I dump all previous data and refresh the form for next sending?


Solution

  • When you close the message box, you should hide the success message container and show the form. That way, when the message box is opened again, you will get the empty form on it.

    $('#close_btn').click(function(){
        $("#myform")[0].reset();
        $("#result").hide();
        $("#myform").show();
    });