How to thank a user by name using Webflow Forms and Javascript

Michael Groff
Michael Groff
YouTube thumbnail showing a successful form submission with the user's name

In this article you'll learn how to make your customers feel more seen and heard by your brand by thanking them by name when they submit a form on your Webflow website using just a few lines of custom JavaScript.

The video above will be explaining this more in depth, so be sure to follow along with the video.

Below is the custom code you'll need to add. Be sure to place the custom code before the closing body tag on your page's custom code.

Make sure you wrap the code below in <script></script> tags.

const submitBtn = document.getElementById('button');
const userName = document.getElementById('name');
submitBtn.addEventListener('click', function() {
  document.getElementById('heading').innerHTML = `Thank you, ${userName.value}!`;

Once the code is added, be sure to add the appropriate element IDs referenced in the video if you haven't already.

Webflow Mistakes 101

Learn the top 5 mistakes startups make in Webflow and how to avoid them in our free, 19 page report.

Get one now