I am using a form to capture basic details such as name, email, website. I'd like to use the input from the website field + a predefined set of characters as a follow-up external URL.
For example website field is: www.example.com
Pre-defined characters are: /123XYZ
The follow-up URL would be www.example.com/123XYZ
As form URLs only allow text my.tokens and nested tokens are not possible to use, is there any other way I can achieve the above?
P.S. I have made sure the website field only captures valid websites such as example.com or www.example.com
Solved! Go to Solution.
P.S. I have made sure the website field only captures valid websites such as example.com or www.example.com
Not sure what you mean by “valid” here, but if the field Website always contains a hostname and you want to swap that hostname into the Thank You URL:
MktoForms2.whenReady(function(mktoForm){
mktoForm.onSuccess(function(submittedValues,baseThankYouURL){
let thankYouLoc = document.createElement("a");
thankYouLoc.href = baseThankYouURL;
thankYouLoc.hostname = submittedValues["Website"];
document.location = thankYouLoc;
return false;
});
});
You would set the Thank You URL in form editor to a placeholder like https://www.example.com/123456. Then at runtime the www.example.com is replaced by whatever the Website value was.
P.S. I have made sure the website field only captures valid websites such as example.com or www.example.com
Not sure what you mean by “valid” here, but if the field Website always contains a hostname and you want to swap that hostname into the Thank You URL:
MktoForms2.whenReady(function(mktoForm){
mktoForm.onSuccess(function(submittedValues,baseThankYouURL){
let thankYouLoc = document.createElement("a");
thankYouLoc.href = baseThankYouURL;
thankYouLoc.hostname = submittedValues["Website"];
document.location = thankYouLoc;
return false;
});
});
You would set the Thank You URL in form editor to a placeholder like https://www.example.com/123456. Then at runtime the www.example.com is replaced by whatever the Website value was.
Thank you so much, this worked!
By "valid" website I meant only example.com or https://example.com are accepted, not simply example or test.