Capitalize first letter of first and last name if not set?


Is it possible to custom code the ability to capitalize the first letter of a field and set the rest to lower case if not set when input by the user?

Hi @Erik1,

I saw one of your other posts and assume you want to format data you send to Marketo. The built in Unbounce integration does eactly what it should, but if you send data through Zapier instead you get so many more options. I use Zapier to keep my CRM data nice and clean.

Use the zap called “formatter” - it will help you capitalize, split fields and perhaps even do what you are looking for here :wink:

1 Like

Ty @Finge! The only issue is we need to concatenate the last name, last 4 of the phone number, add the word ‘Household’ with a space in front, and add the string to a hidden field before sending the data to Marketo.

The final value will look like this: Smith5567 Household

Do you know of any pre-built scripts either here or on github that would help us achieve this?

Unfortunately I don’t, @Erik1. As mentioned Zapier would take of that for your and give you far more control than any script can do.

The only person I can think of who might know something about a script for this would be my fellow Unbounce Expert and scripting overlord @Hristian :blush:

1 Like

We got it!

document.forms[0].addEventListener("submit", function(e){
  this.Company_1.value = 
    this.LastName.value.substr(0,1).toLocaleUpperCase() +
    this.LastName.value.substr(1).toLocaleLowerCase() +
    this.Phone.value.substr(-4) +
    " Household";
1 Like