$( function(){ //問い合わせフォーム $(document).on( 'click', 'a.form_btn,a#fm_btn_send', function(){ $.post( 'inquiry.php', $(this).closest('form').serialize(), function( data ){ var tmp = data.split(""); if ( tmp[0] == 'OK' ) { showMsg( tmp[1] ); } else if ( tmp[0] == 'OK2' ) { showMsg( tmp[1] ); $('#kon_contact div.kon_form').find( 'input[type="text"],input[type="checkbox"],textarea' ).each( function(){ if ( $(this).attr('type') == 'checkbox' ) { $(this).prop( 'checked', false ); } else { $(this).val(''); } } ); } else { $('body,html').animate({scrollTop:$('#kon_contact').offset().top}, 300, 'swing'); showError( data ); } } ); return false; } ); $(document).on( 'click', '#confirm_bourd', function(){ return false; } ); $(document).on( 'click', '#overlay_field,#fm_btn_back', function(){ $('#confirm_bourd').slideUp( 200, function(){ $('#overlay_field').fadeOut( 200, function(){ $('#overlay_field').remove(); } ); } ); return false; } ); } ); function showError( txt ){ if ( $('#overlay_field').length > 0 ) { $('#confirm_bourd').slideUp( 200, function(){ $('#overlay_field').fadeOut( 200, function(){ $('#overlay_field').remove(); } ); } ); } $('#kon_contact div.kon_form #error_area').remove(); $('#kon_contact div.kon_form').prepend( '
' ); $('#kon_contact div.kon_form #error_area').slideUp( 0, function(){ $('#kon_contact div.kon_form #error_area').slideDown( 800, function(){ $('body,html').animate({scrollTop:$('#kon_contact').offset().top}, 300, 'swing'); } ); } ); } function showMsg( txt ){ if ( $('#confirm_bourd').length > 0 ) { $('#confirm_bourd').slideUp( 200, function(){ $('#overlay_field').remove(); showMsg( txt ); } ); return false; } $('body').append( '
' + txt + '
' ); $('#confirm_bourd').slideUp( 0, function(){ $('#confirm_bourd').slideDown( 300 ); } ); }