Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

Autofill Country Field in Form on Index Page



Working on this page, and we'd like to auto fill the COUNTRY field with USA because none of our customers live anywhere else.


I have reviewed all other posts on this topic, and have inserted all suggested code to either autofill, hide, or autofill and hide the country field in Design -> Custom CSS.

The code below almost works, but it throws this error:Your form has encountered a problem. Please scroll down to review.Service Address is missing required subfields: Country

Can anyone help? It seems that a lot of people have this problem, but the solutions that work are from 2017 and predate Squarespace's form verification updates.

     Y.on("domready", function(){
     Y.all('input[name="country"]').setAttribute("value", "US");
   .field.country {
      display: none;

Edited by DebLake
Link to post
  • Answers 1
  • Created
  • Last Reply

Top Posters For This Question

Popular Days

Top Posters For This Question

1 answer to this question

Recommended Posts

  • 0

The JavaScript isn't currently installed on this page but if it was, it wouldn't work.

This is because the form has been added as a lightbox form. These aren't loaded until the user clicks the button to launch it, meaning that the code will load with the page, before the form or the country has been added to it. The code therefore can't precomplete the country information.

If the form was directly on the page, it should (in theory) work as long as Ajax is disabled (the code you've used is old and isn't compatible with it)

Hi, I'm Paul, founder of SF Digitalbuilding the features that Squarespace didn't include. Pick dates in any format, show prices in other currencies, take orders without payment or improve your cartI value honesty, integrity, transparency and respect. Links in my posts may refer to SF Digital products or may be affiliate links.  Squarespace. I've been a loyal supporter of the platform since 2007. 

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

  • Create New...