|
5 | 5 | * SPDX-License-Identifier: Apache-2.0 |
6 | 6 | */ |
7 | 7 | // [START maps_address_validation] |
8 | | -// --- DOM Refs --- |
| 8 | +// DOM Refs |
9 | 9 | const addressForm = document.getElementById('address-form'); |
10 | 10 | const validateButton = document.getElementById('validate-button'); |
11 | 11 | const clearFormButton = document.getElementById('clear-form-button'); |
12 | 12 | const resultDisplay = document.getElementById('result-display'); |
13 | 13 | const loadingText = document.getElementById('loading-text'); |
14 | | -// --- Input field refs --- |
| 14 | +// Input field refs |
15 | 15 | const streetAddress1Input = document.getElementById('street-address-1'); |
16 | 16 | const streetAddress2Input = document.getElementById('street-address-2'); |
17 | 17 | const cityInput = document.getElementById('city'); |
18 | 18 | const stateInput = document.getElementById('state'); |
19 | 19 | const zipCodeInput = document.getElementById('zip-code'); |
20 | 20 | const regionSelect = document.getElementById('region-select'); |
21 | 21 | const exampleSelect = document.getElementById('example-select'); |
22 | | -// --- Core Initialization --- |
| 22 | +// Core Initialization |
23 | 23 | async function init() { |
24 | | - // Load the Address Validation library |
| 24 | + // Load the Address Validation library. |
25 | 25 | await google.maps.importLibrary('addressValidation'); |
26 | 26 | // Set event listeners |
27 | 27 | addressForm.addEventListener('submit', handleValidationSubmit); |
28 | 28 | exampleSelect.addEventListener('change', handleExampleSelectChange); |
29 | 29 | clearFormButton.addEventListener('click', handleClearForm); |
30 | 30 | } |
31 | 31 | // [START maps_address_validation_form_handler] |
32 | | -// --- Validation Handler --- |
| 32 | +// Validation Handler |
33 | 33 | async function handleValidationSubmit(event) { |
34 | 34 | event.preventDefault(); // Prevent default form submission |
35 | 35 | resultDisplay.textContent = 'Validating...'; // Clear previous results |
|
0 commit comments