SOLVED

Can I exclude certain words in form prefill?

Go to solution
mk
Level 2
Level 2

Can I exclude certain words in form prefill?

Hi,

I was wondering if there is a way to have form prefill enabled, but exclude certain words from being prefilled. We use "not entered" on CRM imports to bypass required company and last name fields, but we want to make sure that if someone was created from a CRM import and has a last name or company of "not entered" that it does not get pulled into the form prefill. So essentially, we are hoping to find a way to exclude "not entered" from being populated on all of our forms while still keeping prefill enabled on these fields. 

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Can I exclude certain words in form prefill?


I was wondering if there is a way to have form prefill enabled, but exclude certain words from being prefilled.


Not natively, no. But it can be done easily. Add this JS just before the closing </head> tag:

(function(){
  const effectivelyEmptyValues = ["not entered"];

  Object.keys(mktoPreFillFields)
  .forEach(function(fieldName){
     const fieldValue = this[fieldName];
     if(effectivelyEmptyValues.indexOf(fieldValue) != -1){
        delete mktoPreFillFields[fieldName];
     }
  },mktoPreFillFields);
})();

View solution in original post

1 REPLY 1
SanfordWhiteman
Level 10 - Community Moderator

Re: Can I exclude certain words in form prefill?


I was wondering if there is a way to have form prefill enabled, but exclude certain words from being prefilled.


Not natively, no. But it can be done easily. Add this JS just before the closing </head> tag:

(function(){
  const effectivelyEmptyValues = ["not entered"];

  Object.keys(mktoPreFillFields)
  .forEach(function(fieldName){
     const fieldValue = this[fieldName];
     if(effectivelyEmptyValues.indexOf(fieldValue) != -1){
        delete mktoPreFillFields[fieldName];
     }
  },mktoPreFillFields);
})();