CMS Development

delmer
Member

Forms post-submission conditional logic

SOLVE

When a visitor submits my form, does anyone know how to "redirect to another page" based on conditional logic?  I have a form that is attempting to "pre-qualify" the visitor. If they submit certain form responses, they are to be directed to a "success" page else they are shown a "you don't qualify" page. 

0 Upvotes
1 Accepted solution
Teun
Solution
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

Forms post-submission conditional logic

SOLVE

@delmer , I do not think there is a functionality available for this. So you might need to customze the Form Embed code and write your logic there using the onFormSubmitted callback. You should be able to do something like this:

 

hbspt.forms.create({
      portalId: '',
      formId: '',
      onFormSubmitted: function($form) {
        if ($('input[name="firstname"]').val() === 'something') {
          window.location.href = 'https://example.com'
        } else {
          window.location.href = 'https://example.com'
        }
      } 
});        

 

 



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


View solution in original post

2 Replies 2
Teun
Solution
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

Forms post-submission conditional logic

SOLVE

@delmer , I do not think there is a functionality available for this. So you might need to customze the Form Embed code and write your logic there using the onFormSubmitted callback. You should be able to do something like this:

 

hbspt.forms.create({
      portalId: '',
      formId: '',
      onFormSubmitted: function($form) {
        if ($('input[name="firstname"]').val() === 'something') {
          window.location.href = 'https://example.com'
        } else {
          window.location.href = 'https://example.com'
        }
      } 
});        

 

 



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


delmer
Member

Forms post-submission conditional logic

SOLVE

Thank you, Teun!

0 Upvotes