Book a Free Consultation Squarespace Circle Platinum Partner 2026
All plugins

Autofill the Country in Address Form Field

If you hide the Country form field on a Squarespace form block using CSS, you’ll get an error when you try to submit it because the country is a required field. What if you know that your clients will likely always be in the same country? Unfortunately, you can’t make the country field optional, but you can use the code below to auto-populate this field to fill in your desired country.

This also works on custom product forms.

Put the code below into Pages -> Custom Code -> Code Injection.

<script>
function populateCountry() {
  var field = document.querySelector('.field.country .field-element');
  if (field) {
    field.value = 'United States';
  } else {
    setTimeout(populateCountry, 500);
  }
}
populateCountry();
</script>

Customization:

To change the country, change ‘United States’ to the country of your choice.

OlderMake All Accordion Divider Lines the Same Height Newer Force Mobile Navigation on Desktop (7.1)

Let’s collaborate & create a website you can’t wait to show your friends and family!

Book a Free Consultation