Reset Fields on AMP Form Submission

Viewed 1992

I want to reset all the form fields on successful AMP form submission as I am allowing user for multiple data entry.

Manually I can do it by managing states of each field through amp-bind but I want to reset fields in one go. Is there any function like form.reset present which I can call on form submit success event?

2 Answers

You can use the clear action to reset all fields in a form:

<form id=myForm>
  <input>
</form>
<button on="tap:myForm.clear">Clear inputs</button>

You can use submit-success.

<form id=myForm on=submit-success: myForm.clear>
  <input name=name value= />
<button>Submit form</button>
</form>
Related