How Do I Set A Form's Success Message Or Redirect?
By default a submitted form shows "Message sent." without reloading the page. Add data-oxy-success="..." to change the message, data-oxy-redirect="/thanks.html" to send the visitor to a thank-you page, or data-oxy-success-selector="#thanks" to reveal a hidden element instead.
Updated
By default, a form submits in the background without reloading the page. The fields are cleared and the text "Message sent." appears just after the submit button. If you want something else, add one attribute to your form tag - no scripting needed.
Custom Success Message
<form data-oxy-form="contact" data-oxy-success="Thanks, we reply within a day.">
The visitor stays on the page and sees your text instead of the default.
Redirect To A Thank-You Page
<form data-oxy-form="contact" data-oxy-redirect="/thanks.html">
After a successful submission the visitor is sent to that address. The
value can be a path on your site (starting with /) or a full https://
address.
Reveal A Hidden Element
<form data-oxy-form="contact" data-oxy-success-selector="#thanks">
On success the form is hidden and the element matching the selector is
shown. Give that element the hidden attribute in your HTML so it stays
invisible until then.
Custom Error Message
If a submission fails, the default text is "Could not send - please try
again." Override it with data-oxy-error="Your own text here.".
For Developers
The form fires oxy:submitted and oxy:error events you can listen for,
and data-oxy-native opts a form out of the background-submit helper
entirely so the browser posts it natively.