Form validation / error message + not allow duplicate email

SOLVE
ikknd
Participant

We have a form where users can ask for a demo account.

- How can we prevent users from submitting form again, with the same email address?

- In Hubspot form setting I have only seen option to redirect to another page OR display a thank you message - is it possible to have both? 

- Is it possible to first validate if email can be used, if no - display an error message that this email has already been used?

0 Upvotes
2 Accepted solutions

Accepted Solutions
amwilie
Solution
Key Advisor | Elite Partner

@Kevin-C They would have to delay the redirect though. I've often run into a problem with trying to use contact properties right after form submission and the submission not having updated the contact quick enough to be usable.

 

@ikknd He's not talking about using the API, but instead using a contact property after form submission to determine what content is shown on the page you redirect to either using HubL or smart content.

 

I don't believe Hubspot has any sort of  validation available in their API. If you want to validate before/on submission you would need to use the Contacts API to get the contact by their email and then you can either search for a property in the form to see if it's filled out or have a list that users are being put into on form submission and see if they're in that list. Then submit the form or show an error depending on if they're in the list/have the property or not. @Kevin-C does mention serverless functions, this would allow you to use the API without an integration but it's an Enterprise only feature.

 

That's about as much as I can tell you. I don't really work with the APIs much. 😅

border

Alyssa Wilie

Web Developer at LyntonWeb

If this answer solved your question, please mark it as the solution!

View solution in original post

Kevin-C
Solution
Recognized Expert

Yeah I kinda forgot what forum I was in and went on a tanget…

 

Back on track!

The V3 CRM API will return an error if you try to create a contact with a duplicate email address.

Alternatively using the READ (get) or SEARCH(post) endpoint you could manually compare the values.

 

Below I've include a few successful test responses:

 

CREATE:

KevinC_2-1625091501959.png

 

SEARCH:

KevinC_1-1625091463456.png

 

READ:

KevinC_0-1625091417982.png

 

 

View solution in original post

10 Replies 10
dennisedson
Community Manager

@Kevin-C , @amwilie --> any thoughts on these questions? 

Thanks,

Dennis




Check out our Community Developer Blog
where we feature our Community driven developer podcast and how to content
0 Upvotes
amwilie
Key Advisor | Elite Partner

I don't believe this is something you can do efficiently with HubL, javascript, or workflows unless the user's cookie stays intact (which is unlikely), so sorry @dennisedson but I'm no help here. I'm not an API guru 😅

border

Alyssa Wilie

Web Developer at LyntonWeb

If this answer solved your question, please mark it as the solution!

Kevin-C
Recognized Expert

Thanks @dennisedson 

 

Hey @ikknd 

 

I also believe @amwilie is correct. But your usecase leads me to believe there might be other options.

 

I'm wondering if this has to be an api / validation thing. What if the content on the page the contact is redirected to is conditional?

Maybe a hidden boolean contact info field in the form. Then on the redirected page query against that field.

This way we declare what we want to happen based on the contacts info vs checking the submission.

 

I could also see something like this being done with a serverless function, if you have access to them. But I still feel like the first option might serv you better.

 

@amwilie @dennisedson  Thoughts?

Kevin-C
Recognized Expert

I also feel like the first option would avoid more edgecases, while allow you to scale in the future if desired.

0 Upvotes
ikknd
Participant

@Kevin-C Thank you for the suggestions.

I am a bit new to Hubspot integrations, could you clarify which api/validation are you talking about?

Is there API that Hubspot offers, that I could use for email "duplicate" validation?  Or is this something that we need to develop by ourselves?

 

Basically we need to do the validation before the form is submitted, via javacript?

Kevin-C
Solution
Recognized Expert

Yeah I kinda forgot what forum I was in and went on a tanget…

 

Back on track!

The V3 CRM API will return an error if you try to create a contact with a duplicate email address.

Alternatively using the READ (get) or SEARCH(post) endpoint you could manually compare the values.

 

Below I've include a few successful test responses:

 

CREATE:

KevinC_2-1625091501959.png

 

SEARCH:

KevinC_1-1625091463456.png

 

READ:

KevinC_0-1625091417982.png

 

 

View solution in original post

Kevin-C
Recognized Expert
I’m now wondering if we could check if the contact has filled out the form before? I’ll have to get back to this.
ikknd
Participant

@Kevin-C thank you so much for the help, now I know which direction to take

0 Upvotes
amwilie
Solution
Key Advisor | Elite Partner

@Kevin-C They would have to delay the redirect though. I've often run into a problem with trying to use contact properties right after form submission and the submission not having updated the contact quick enough to be usable.

 

@ikknd He's not talking about using the API, but instead using a contact property after form submission to determine what content is shown on the page you redirect to either using HubL or smart content.

 

I don't believe Hubspot has any sort of  validation available in their API. If you want to validate before/on submission you would need to use the Contacts API to get the contact by their email and then you can either search for a property in the form to see if it's filled out or have a list that users are being put into on form submission and see if they're in that list. Then submit the form or show an error depending on if they're in the list/have the property or not. @Kevin-C does mention serverless functions, this would allow you to use the API without an integration but it's an Enterprise only feature.

 

That's about as much as I can tell you. I don't really work with the APIs much. 😅

border

Alyssa Wilie

Web Developer at LyntonWeb

If this answer solved your question, please mark it as the solution!

View solution in original post

ikknd
Participant

@amwilie thank you for your help, this has clarified a lot of questions I had