Skip to main content

๐Ÿ“ฎ Change Country Field Default on an Address Block

Address blocks default the Country field to United States ๐Ÿ‡บ๐Ÿ‡ธ. What a particular form is targeted to international students? ๐ŸŒ

You can change the default country for your entire Slate instance under Database > Configuration keys, but some items may still default to US as ofย September 2023.

Place any of the following code examples you want to use into theย form scripts box.

You can set Country to blank:

// Wait for the page to finish loading
$(window).on("load", function () {
    // Set the Country field to blank
    $("[data-export='sys:address'] [name$='_country']").val('');
    // Trigger change handler to update the region list
    $("[data-export='sys:address'] [name$='_country']").change();
});
// Wait for the page to finish loading
$(window).on("load", function () {
    // Set the Country field to blank
    $("[data-export='sys:address'] [name$='_country']").val('CA');
    // Trigger change handler to update the region list
    $("[data-export='sys:address'] [name$='_country']").change();
});

The list of country codes can be found in the HTML source of the form. It appears to follow the ISO 3166-1 alpha-2 list.

You can also make the country field un-editable:

$(window).on("load", function () {
  $('#').disable().attr("data-disabled", "1").css({
    border: "1px solid rgb(204, 204, 204)",
    color: "rgb(102, 102, 102)"
  });
});