Advanced validation in an N8N form

Hi

Is it somehow possible to create this flow:

  1. I create a form with a text field. I need the user to enter a text that is in a very specific format

  2. I create a code node (or IF-node) and checks whether the submitted text is valid

  3. If not valid, I somehow redirect back to the form with an error message?

  4. If valid, the workflow continues

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @systemaddict,

That’s a good question! What kind of validation will you be running on your submitted text? One idea I can think of quickly would be to use the n8n Form Ending node to redirect user to the initial form page if the submitted text isn’t valid, although you probably won’t be able to throw an error message:

Yes, it was something like this that I had in mind, but it will be difficult for the users to understand without the error message.

I think that could be a nice addition to the form functionality, perhaps as simple as being able to pipe a url parameter into the form somehow (that could be added in the redirect sted).

1 Like

Alternatively, you can use the Form Ending node to simply throw and error message and instructing the user to try again by reloading, or adding the redirect URL in the description of the node etc. Feel free to write a feature request in the Feature request section of the forum and upvote :slight_smile:

Hey @systemaddict,

What about something like this, So we check the output of the first form and if it isn’t what we want we change the description in the next form to say it is incorrect and show the same questions and just have that in a loop.

1 Like

Yes, that is actually a nice solution. It does seem a little redundant with two similar forms, but I think that will work for now. Thanks for the tip.

1 Like

No problem, It is the best I can think of at the moment. I have added a feature request for adding some validation options like character length or regex pattern matching.