$(function(){ $(window).on('load',function(){ if($(window).width() <= 768){ var foot_height = $('.foot_tel').innerHeight(); $('footer ul').css('margin-bottom',foot_height); } }); $('#inputform').submit(function(e) { if(validate($(this))){ closeblock($(this)); return false; }else{ return false; } }); $(document).on('change', 'select[name="prefecture"]', function(e) { $('select[name="city"] option').remove(); $('select[name="city"]').append($('選択して下さい')); Object.keys(city_array[$(this).val()]).forEach(function (key){ $('select[name="city"]').append($('').html(key).val(key)); }); }); $(".place .item h3").on("click", function () { $(this).parent().find('.value').toggle(500); $(this).toggleClass('on'); }); $('input[name="photo"]').on('change', function() { $('.photo_value').remove(); $('.inputphoto').remove(); $(this).parent('label').after(''+$(this).prop('files')[0].name+''); }); var target = document.querySelector('.ct3_telno'); if (target) { var observer = new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { console.log('内容が変わった! → ' + $(target).text()); $('.telhead').attr('href','tel:'+$(target).text()); $('.tel_btn').attr('href','tel:'+$(target).text()); $('.telfoot').attr('href','tel:'+$(target).text()); }); }); observer.observe(target, { childList: true, characterData: true, subtree: true }); } }); function validate(thisdata){ $('.error_val').remove(); var error_chk = 0; // if(!$('select[name="place"] option:selected').val()){ // $('input[name="place_etc"]').after('場所は一つ以上選択してください'); // $('select[name="place"]').after('場所は一つ以上選択してください'); // error_chk = 1; // }else if($('.place_etc').prop('checked') && !$('input[name="place_etc"]').val()){ // $('input[name="place_etc"]').after('その他の詳細を入力してください'); // error_chk = 1; // } // if(!$('input[name="_name"]').val()){ // $('input[name="_name"]').after('氏名は必須項目です'); // error_chk = 1; // } // if(!$('input[name="_furi"]').val()){ // $('input[name="_furi"]').after('フリガナは必須項目です'); // error_chk = 1; // } // if(!$('input[name="_email"]').val()){ // $('input[name="_email"]').after('メールアドレスは必須項目です'); // error_chk = 1; // } // if($('input[name="_email"]').val() != $('input[name="_email_chk"]').val()){ // $('input[name="_email_chk"]').after('メールアドレスが確認用と一致しません'); // error_chk = 1; // } var telval = $('input[name="_tel"]').val(); telval = telval.replace(/━|‐|―|-|\-|ー|\-/g,''); if(!$('input[name="_tel"]').val()){ $('input[name="_tel"]').after('電話番号は必須項目です'); error_chk = 1; }else if(!telval.match(/^\d{11}$/)){ $('input[name="_tel"]').after('電話番号は半角数字で入力してください'); error_chk = 1; } // if(!$('input[name="_zip"]').val()){ // $('input[name="_zip"]').after('郵便番号は必須項目です'); // error_chk = 1; // } // if(!$('select[name="land"] option:selected').val()){ // $('select[name="land"]').after('地域は必須項目です'); // error_chk = 1; // } // if(!$('input[name="_city"]').val()){ // $('input[name="_city"]').after('市区町村は必須項目です'); // error_chk = 1; // } // if(!$('input[name="_banti"]').val()){ // $('input[name="_banti"]').after('丁目・番地は必須項目です'); // error_chk = 1; // } // if(!$('input[name="emergency"]:checked').val()){ // $('input[name="emergency_etc"]').after('お問い合わせの緊急度は必須項目です'); // error_chk = 1; // }else if($('.emergency_etc').prop('checked') && !$('input[name="emergency_etc"]').val()){ // $('input[name="emergency_etc"]').after('その他の詳細を入力してください'); // error_chk = 1; // } // if(!$('select[name="hour"] option:selected').val()){ // $('select[name="hour"]').after('ご連絡可能な時間帯は必須項目です'); // error_chk = 1; // } if(!$('input[name="agree"]:checked').val()){ $('input[name="agree"]').parent('label').after('個人情報の取り扱いに同意してください'); error_chk = 1; } if(error_chk){ alert('入力内容に不備がありますので、各項目を確認してください。'); $(window).scrollTop($('#contact').position().top); return false; }else{ return true; } } function closeblock(thisdata){ var data = { 'entry_id': $('#inputform input[name="entry_id"]').val(), 'place': $('#inputform select[name="place"] option:selected').val(), 'incident': $('#inputform select[name="incident"] option:selected').val(), '_name': $('#inputform input[name="_name"]').val(), '_tel': $('#inputform input[name="_tel"]').val(), '_zip': $('#inputform input[name="_zip"]').val(), 'land': $('#inputform select[name="land"] option:selected').val(), '_city': $('#inputform input[name="_city"]').val(), 'contact_distinct_comp': $('#inputform input[name="contact_distinct_comp"]').val(), 'contact_distinct_affi': $('#inputform input[name="contact_distinct_affi"]').val() } $.ajax({ url: '/e_start/travel/php/send_contact_mail.php', data: data, type: 'POST', timeout: 50000, }).done(function(data) { if(data.data.error){ alert(data.data.message); }else{ location.href = '/e_start/travel/thanks.html?composure_id=' + data.data.composure_id + '&entry_id=' + data.data.entry_id + '&af=' + $('#inputform input[name="af"]').val(); } }).fail(function(errors) { }) }