PageSourceSearch

https://www.tainavi-next.com/wp-content/themes/twentysixteen/common/js/ajaxzipFooter_cta.js

js tainavi-next.com collected 2026-10-04 17:58:15 UTC 9,002 bytes, 192 lines download raw bytes

1window.onpageshow = function(){
2    if($('input[name="zip_foot"]').length){
3        AjaxZip3.zip2addr('zip_foot','','pref_foot','address1_foot','address2_foot');
4    }
5}
6const prefectures = [
7    "北海道","青森県","岩手県","宮城県","秋田県","山形県","福島県",
8    "茨城県","栃木県","群馬県","埼玉県","千葉県","東京都","神奈川県",
9    "新潟県","富山県","石川県","福井県","山梨県","長野県",
10    "岐阜県","静岡県","愛知県","三重県",
11    "滋賀県","京都府","大阪府","兵庫県","奈良県","和歌山県",
12    "鳥取県","島根県","岡山県","広島県","山口県",
13    "徳島県","香川県","愛媛県","高知県",
14    "福岡県","佐賀県","長崎県","熊本県","大分県","宮崎県","鹿児島県","沖縄県"
15  ];
16$(window).on('load', function() {
17    // 郵便番号変更による都道府県選択の無効化フラグ
18    //let isZipChange = false;
19
20    // 都道府県プルダウンに追加(valueも名前)
21    $.each(prefectures, function (i, name) {
22        $('.js-prefSelect').append(`<option value="${name}">${name}</option>`);
23    });
24
25    // 都道府県選択時にJSONを読み込み市区町村を更新
26    $('.js-prefSelect').on('change', function () {
27        //リセット
28        $(this).parents('.js-ft-cta').find(":input[name=pref_foot]").val("");
29        $(this).parents('.js-ft-cta').find(":input[name=address1_foot]").val("");
30        $(this).parents('.js-ft-cta').find(":input[name=address2_foot]").val("");
31        $(this).parents('.js-ft-cta').find('.js-zip-foot').val("");
32
33        const selectedPrefName = $(this).val();
34        if(selectedPrefName == ""){
35            $(this).parents('.js-ft-cta').find('.js-city-box').addClass('is-hide');
36        }else{
37            $(this).parents('.js-ft-cta').find('.js-city-box').removeClass('is-hide');
38        }
39        $(this).parents('.js-ft-cta').find(":input[name=pref_foot]").val(selectedPrefName);
40
41        const citySelect = $(this).parents('.js-ft-cta').find('.js-citySelect');
42        citySelect.empty().append('<option value="">-- 市区町村を選択 --</option>');
43
44 
45
46        if (!selectedPrefName) {
47        citySelect.prop('disabled', true);
48        console.log(selectedPrefName);
49        return;
50        }
51
52        // 都道府県名からインデックス(01〜47)を取得
53        const index = prefectures.indexOf(selectedPrefName);
54        if (index === -1) {
55        alert('選択された都道府県が無効です。');
56        citySelect.prop('disabled', true);
57        return;
58        }
59        const formAction = $('.js-api-host').attr('action');
60        const url = new URL(formAction);
61        const urlPass = `${url.protocol}//${url.hostname}`;
62        //console.log(urlPass);
63
64        const prefCode = (index + 1).toString().padStart(2, '0');
65        const filePath = `${urlPass}/data/pref-${prefCode}.json`;
66
67        $.getJSON(filePath, function (json) {
68        const cities = json[2].map(city => city[1]);
69        $.each(cities, function (i, cityName) {
70            citySelect.append(`<option value="${cityName}">${cityName}</option>`);
71        });
72        citySelect.prop('disabled', false);
73        }).fail(function () {
74        //alert('JSONファイルの読み込みに失敗しました。');
75        alert('都道府県の取得に失敗しました。');
76        citySelect.prop('disabled', true);
77        });
78    });
79    // 市区町村プルダウン
80    $('.js-citySelect').on('change', function () {
81        const selectedCityName = $(this).val();
82        $(this).parents('.js-ft-cta').find(":input[name=address1_foot]").val(selectedCityName);
83    });
84     // 郵便番号
85     $('.js-zip-foot').on('change', function () {
86
87        // リセット
88        $(this).parents('.js-ft-cta').find(".js-prefSelect").val("");
89        $(this).parents('.js-ft-cta').find('.js-citySelect').val("");
90        $(this).parents('.js-ft-cta').find('.js-city-box').prop('disabled', true);
91        $(this).parents('.js-ft-cta').find('.js-city-box').addClass('is-hide');
92
93    });
94
95
96
97//入力補助
98//===============================================
99    $(":input[name^=zip_foot]").blur(function(){
100        var val = $(this).val();
101        var han = val.replace(/[0-9]/g,function(s){return String.fromCharCode(s.charCodeAt(0)-0xFEE0)});
102        if(val.match(/[0-9]/g)){
103            $(this).val(han);
104        }
105    });
106    $(":input[name=panel_set_area_foot]").blur( function(){
107        var val = $(this).val();
108        var han = val.replace(/[0-9]/g,function(s){return String.fromCharCode(s.charCodeAt(0)-0xFEE0)});
109        if(val.match(/[0-9]/g)){
110            $(this).val(han);
111        }
112    });
113
114
115//バリデート
116//===============================================
117    //選択タイプCTAクリック時
118    $(document).on('click','.js-cta-change-type-submit-btn',function(){
119        if($(this).parents('.js-ft-cta').find(":input[name=pref_foot]").val() == "" || $(this).parents('.js-ft-cta').find(":input[name=address1_foot]").val() == ""){
120            alert("正しい郵便番号を入力して下さい。\nもしくは\n都道府県と市区町村を選択してください。");
121            return false;
122        }else{
123            // if($(this).parents('.js-ft-cta').find(":input[name=zip_foot]").val() == ""){
124            //     const tar_url = new URL($('.js-api-host').attr('action')).hostname;
125            //     if(tar_url.includes("www")){
126            //         //都道府県プルダウン
127            //         gtag('event', 'click', {
128            //             'event_category': 'cta',
129            //             'event_label': 'prefSelect-click'
130            //         });
131            //     }
132            // }
133            return true;
134        }
135    });
136
137
138
139    //下層CTAクリック時
140    $(document).on('click','.js-image_foot_btn',function(){
141    //$(".js-image_foot_btn").click(function() {
142            var err_msgs = "";
143
144            if ($(this).parents('.js-ft-cta').find(":input[name=pref_foot]").val() == "" || $(this).parents('.js-ft-cta').find(":input[name=address1_foot]").val() == "") {
145                err_msgs = "郵便番号が正しく入力されているか確認してください。\n";
146            }
147
148            var type = $(this).parents('.js-ft-cta').find('form').attr('data-type');
149
150            if(type == "investment"){//投資目的フォームの場合
151
152                var val =$(this).parents('.js-ft-cta').find('[name="zip_foot"].js-fit-post').val();
153                if(!val.match(/^\d+$/) || val.length != 7){
154                    err_msgs = "郵便番号が正しく入力されているか確認してください。\n";
155                }
156
157                var panel_set_cd_foot_value = $(this).parents('.js-ft-cta').find(':input[name="panel_set_cd_foot"]:checked').val();
158
159                if ($(this).parents('.js-ft-cta').find(":input[name=panel_set_area_foot]").not('.js-hidden-val').val() == "") {
160                    err_msgs += "設置予定場所の面積を入力して下さい。\n";
161                } else if(!$(this).parents('.js-ft-cta').find(":input[name=panel_set_area_foot]").not('.js-hidden-val').val().match(/^[0-9\.]+$/)){
162                    err_msgs += "設置予定場所の面積が間違っています。\n";
163                } else if($(this).parents('.js-ft-cta').find(":input[name=panel_set_area_foot]").not('.js-hidden-val').val().length > 13){
164                    err_msgs += "設置予定場所の面積は13桁以内で入力して下さい。\n";
165                }
166
167
168                if (panel_set_cd_foot_value != 1 && panel_set_cd_foot_value != 2) {
169                    err_msgs += "平米・坪いずれかを選択して下さい。\n";
170
171                } else if((panel_set_cd_foot_value == 1 && $(this).parents('.js-ft-cta').find(":input[name=panel_set_area_foot]").not('.js-hidden-val').val() != '' && $(this).parents('.js-ft-cta').find(":input[name=panel_set_area_foot]").not('.js-hidden-val').val() < 1200) || (panel_set_cd_foot_value == 2 && $(this).parents('.js-ft-cta').find(":input[name=panel_set_area_foot]").not('.js-hidden-val').val() != '' && $(this).parents('.js-ft-cta').find(":input[name=panel_set_area_foot]").not('.js-hidden-val').val() < 400)){
172                    err_msgs += "設置面積が400坪未満・1200平米未満の方はご利用できません。";
173                }
174            }else{
175                var val =$(this).parents('.js-ft-cta').find('[name="zip_foot"].js-self-post').val();
176                if(!val.match(/^\d+$/) || val.length != 7){
177                    err_msgs = "郵便番号が正しく入力されているか確認してください。\n";
178                }
179            }
180
181            if (err_msgs!="") {
182                alert(err_msgs);
183                return false;
184            } else {
185                //var obj = document.forms["form_foot"];
186                    //obj.submit();
187                return true;
188            }
189    });
190
191
192});

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.