Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form does not reset after successful submission #283

Closed
philou2016 opened this issue Sep 18, 2018 · 15 comments
Closed

Form does not reset after successful submission #283

philou2016 opened this issue Sep 18, 2018 · 15 comments

Comments

@philou2016
Copy link

My form doesn't refresh automatically after sent....

@mckennapsean
Copy link
Collaborator

Not sure what that means.

@philou2016
Copy link
Author

philou2016 commented Sep 18, 2018 via email

@mckennapsean
Copy link
Collaborator

It is hard to reproduce this. Do you have an example with the failure you mentioned? Can you share it?

In your case... the form is never cleared by our script I think, but you can add this functionality if desired (we simply hide the form and show a thank-you message). This could be why you are seeing what you are seeing.

@KamranArshad11
Copy link

I have a similar issue with the form.
When I input data in the fields and press SEND button the page doesn't refresh and it does not display thank you message as well, despite the fact that the email is received into my inbox.

Thanks

@mckennapsean
Copy link
Collaborator

Can you share an example where this issue is happening?

From what I can tell, @philou2016 in fact did get the thank you message, so this is already different from your issue. My guess is that the main form is not getting hidden and it does not clear the form automatically, this feature needs to be added for your case. An example of this would allow me to help you more easily.

@KamranArshad11
Copy link

@mckennapsean I have followed each and every step of the tutorial. The output according to the tutorial is correct until step 9.
This is the send button that I am using,

and using the .js file that is provided in the tutorial.

Please tell me what is the issue here. Please also tell me anything you want from the code to help me.

Thanks

@mckennapsean
Copy link
Collaborator

If you share any HTML where this issue is occurring, I may be able to help. Our examples work and don't have this issue, so it's likely from a difference in the HTML.

@KamranArshad11
Copy link

I am using this theme. I have attached the whole project so that it will be easy for you to understand.
theme.zip

@mckennapsean
Copy link
Collaborator

Thanks for posting that @KamranArshad11 ! As I expected, your form has no form-elements or thankyou_mesage classes, so the content is not getting hidden nor is a thank you message popping up.

To simply reset the form after a submission, all you have to do is add this line to the onreadystatechange before the final return: form.reset(); Then it will clear the form once it is submitted (though doesn't handle any error cases). This is simple enough for a PR, if you are interested. 👍

@mckennapsean mckennapsean changed the title form problem Form does not reset after successful submission Oct 3, 2018
@mckennapsean
Copy link
Collaborator

We likely want to make sure that resetting only occurs if the form is successfully submitted. And we could show an error message on failure. If that is beyond scope for someone on this PR, I will follow up and do this.

@KamranArshad11
Copy link

@mckennapsean thank you very much. You have been very helpful. Thanks a lot

@chantelletjie
Copy link

Hi, I know I am also having trouble with my contact form. I think I might have missed a step or two in the instructions, but I would honestly appreciate your help.

The reseting part is not happening and no thank you message is appearing. Have I not entered or linked the code properly? or am I missing a few code elements?

Kind regards.

contact form submition.zip

@mckennapsean
Copy link
Collaborator

Have you read the FAQs? They walk through the most common errors I see. I would suggest that, trying to look at the console log, putting breakpoints in the debugger to see if the code is getting hit. Probably isn't.

@mckennapsean
Copy link
Collaborator

Just need to add form.reset() within the xhr's onreadystate change function. That worked for me. Anyone can open a PR for it, otherwise I can do it easy peasy.

@mckennapsean
Copy link
Collaborator

Thanks @jchesner for sharing that insight!

nelsonic added a commit that referenced this issue Feb 19, 2019
Reset the web form on successful submission, fixes #283
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants