Hello,
On our most used form, we require the person to enter their company website. As the website field is a URL field, it is requiring the user to enter the http protocol in the website they are entering. I would suspect that this rigorous requirement is dropping our form fills.
Is there a way to not require the http protocol before the web address? I know forms 2.0 does have some additional validation techniques, but I have not kicked the tires on it yet.
Thanks,
Kyle
Solved! Go to Solution.
The better way is to parse their email domain...
Marketo actually populates Website from the Email Address domain by default. Problem is, that's not guaranteed to be accurate. A lead can use their personal email address to sign up for a trial, but would be OK w/providing the actual company domain on the form (think enterprise web software, etc.).
Use a string or text field and clean it up later using JS or in SFDC.
Depends how badly you want "https" in there.
The better way is to parse their email domain and/or use an enrichment service later on in Marketo/SFDC. Why ask someone for their domain ?
The better way is to parse their email domain...
Marketo actually populates Website from the Email Address domain by default. Problem is, that's not guaranteed to be accurate. A lead can use their personal email address to sign up for a trial, but would be OK w/providing the actual company domain on the form (think enterprise web software, etc.).
Thanks Sanford. Tested and this is the case, but to your point does have a drawback that we would be willing to live with.
Thanks Josh. I agree with this sentiment but deleted it from my original post.
Posted this code the other day in response to an almost identical question (unfortunately, the forum search feature is really bad so I can't even find that thread now!).
This code will do naive validation of a String field as being domain-name-like, with at least a 2-part name. It also allows but doesn't require http:// or https://:
/*
* @author Sanford Whiteman
* @version v1.0.6 2020-11-11
* @copyright © 2020 Sanford Whiteman
* @license Hippocratic 2.1: This license must appear with all reproductions of this software.
*
*/
MktoForms2.whenReady(function(mktoForm){
const formEl = mktoForm.getFormElem()[0];
mktoForm.onValidate(function(nativeValid){
const hostnameFields = ["Website"],
hostnameMsg = "Must be a valid domain/subdomain name";
/* NO NEED TO TOUCH BELOW THIS LINE */
if (!nativeValid) return;
let currentValues = mktoForm.getValues(),
originalSubmittable = mktoForm.submittable(),
firstOffender;
const RE_DOMAIN_NAIVE = /^(https?:\/\/)?(?:[a-z0-9][a-z0-9-]{0,61}[a-z0-9]?)(?:\.[a-z0-9][a-z0-9-]{0,61}[a-z0-9]?)*(?:\.[a-z0-9][a-z0-9-]{0,61}[a-z0-9])$/i;
hostnameFields.some(function(fieldName){
if( !RE_DOMAIN_NAIVE.test(currentValues[fieldName]) ){
firstOffender = formEl.querySelector("[name='"+ fieldName + "']");
return false;
}
});
if(firstOffender){
mktoForm.submittable(false);
mktoForm.showErrorMessage(hostnameMsg,MktoForms2.$(firstOffender));
} else {
mktoForm.submittable(originalSubmittable);
}
});
});