Dynamic form redirection


I have a form with a custom success page in the action attribute of the form like this:


Depending of certain form values, I update via JavaScript the action attribute to redirect to a different success page (for example /congratulations), however it always takes me to the default /thanks page.

Is this behavior unsupported?


Yup, it is. We record the action at DEPLOY time, and you cannot change it. Perhaps your result page could have conditional behavior instead of trying to have a conditional page address?


Another option is to use Netlify functions to handle the form submission and redirect.

Here is an example of how to do dynamic redirects with functions https://github.com/DavidWells/netlify-functions-workshop/blob/master/lessons-code-complete/use-cases/3-redirects/functions/redirect.js

On the frontend you would want to point your form action to the function url