PageSourceSearch

https://hopnic.co.jp/wp/wp-content/themes/hopnic/js/zip-search.js

js hopnic.co.jp collected 2026-10-06 17:24:20 UTC 1,733 bytes, 34 lines download raw bytes

1document.addEventListener('DOMContentLoaded', function() {
2    var postalCode1Field = document.getElementById('address_zip1');
3    var postalCode2Field = document.getElementById('address_zip2');
4    var searchButton = document.getElementById('search-address-button');
5    var prefectureField = document.getElementById('address_prefectures');
6    var addressField = document.getElementById('address');
7
8    if (postalCode1Field && postalCode2Field && searchButton) {
9        searchButton.addEventListener('click', function() {
10            var postalCode1 = postalCode1Field.value.replace(/[^0-9]/g, '');
11            var postalCode2 = postalCode2Field.value.replace(/[^0-9]/g, '');
12            if (postalCode1.length === 3 && postalCode2.length === 4) {
13                var postalCode = postalCode1 + postalCode2;
14                fetch('https://zipcloud.ibsnet.co.jp/api/search?zipcode=' + postalCode)
15                    .then(response => response.json())
16                    .then(data => {
17                        if (data.results) {
18                            var result = data.results[0];
19                            prefectureField.value = result.address1;
20                            addressField.value = result.address2 + result.address3;
21                        } else {
22                            alert('住所が見つかりませんでした。');
23                        }
24                    })
25                    .catch(error => {
26                        console.error('Error:', error);
27                        alert('住所検索に失敗しました。');
28                    });
29            } else {
30                alert('正しい郵便番号を入力してください。');
31            }
32        });
33    }
34});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.