Answered

How do I store an email address in a hidden field?

  • 13 July 2023
  • 4 replies
  • 113 views

Before sending users to an embedded typeform in my web site, I ask for the user's email address, and then pass that as a hidden variable to typeform, and eventually use it when typeform posts to my web hook.

Generally speaking this works fine, but every once in a while someone manages to sneak in an empty email address, which my backend doesn't like.

To prevent this, I could check the hidden field in typeform and if it's empty, send people to a Contact Info form where I ask for the email address, or, if the email address was already entered, just send them straight to my real quiz.

If I go this route, how do I tell typeform to put the email address collected in that first Contact Info into the hidden email variable? I don't see a way to make that connection.

icon

Best answer by rowe8l 13 July 2023, 21:53

View original

4 replies

Userlevel 7
Badge +5

Hi @rowe8l How are you asking for the email address before sending them to the typeform? Is that another typeform? 

The other code is in React, and it checks cookies, and if the email address is there, it passes it on, or it redirects to the signup form to get the email address. Again, that usually works as expected. Just every once in a while we somehow get a web hook call where that hidden field is "".

My question here is really just about how I can make sure on the typeform side, that a hidden variable is set. I thought about asking the user for their email address (should work in this case), but I'd be fine with displaying an error and blocking them from the typeform content as well (would be needed if the hidden field holds something like an internal id that the user cannot simply enter).

 

I found a way to block people if the hidden field is not passed. It's not great, but I hope it will work.

First step in my quiz is a form that checks for the hidden fields. If email is empty, I send the user to a new form that has an error message. Since I have to have a button, I just have that send the user to another error form with the URL they should go to in order to start over. Again, I have to have a button, which takes the user back to the previous error form. If the hidden field is set, I send the user to the real typeform quiz.

 

Please don't break this by detecting and disallowing infinite loops :-)

Userlevel 7
Badge +5

Hi @rowe8l Ah, glad you were able to find a solution that works! Let us know if you think of any other questions. 

Reply