$(function() { $('.motivo_viaggio').change(function() { if ( $('#motivo_viaggio_svago').prop('checked') ) { $('.mlavoro').addClass('hide'); $('.msvago').removeClass('hide'); } else { $('.msvago').addClass('hide'); $('.mlavoro').removeClass('hide'); } }); }); function hotel( i_hotel, action ) { if ( action == 'si' ) { $( '.fg-hotel_dove_' + i_hotel ).removeClass('hide'); if ( $( '#cmbHotelDove_' + i_hotel ).val() == 'vicino a' ) { $( '.fg-hotel_vicinoa_' + i_hotel ).removeClass('hide'); } } else { $( '.fg-hotel_dove_' + i_hotel + ', .fg-hotel_vicinoa_' + i_hotel ).addClass('hide'); } } function fSaveData() { $('submit').focus(); $('#submitBut').addClass('hide'); $('#submitLoad').removeClass('hide'); $('#txtNote').val( ($('#txtNote').val()).replace(/[\r\n]/gm, '[n]') ); var data; var strDestination = ''; var blnSaved = false; $.ajax({ type: "POST", async: false, dataType: "json", url: "/tpl/default/assets/ajax/sendConsulente.php", data: $("#frmConsulente").serialize(), success: function(data) { strDestination = data.destination; if ( data.status == 'ok' ) { blnSaved = true; } else swal("Oops!", "出问题了。", "error"); }, error: function(data){swal("Oops!", "出问题了。", "error");} }); if ( blnSaved ) { location.href = strDestination; } else { $('#submitLoad').addClass('hide'); $('#submitBut').removeClass('hide'); } } // Controllo campi obbligatori function fCheckObbligatori() { var blnReturn = true; $( ".form-group" ).removeClass( "has-error" ); $( ".lbl" ).html(""); var blnLavoro = $('#motivo_viaggio_lavoro').prop('checked'); $('.required').each(function() { if ( $.trim( $(this).val() ) == "" ) { blnReturn = false; $( "#lbl" + $(this).attr("name") ).html( fHTMLErrore( "" ) ); $( ".fg-" + $(this).attr("name") ).addClass( "has-error" ); } }); // Controllo privacy if ( ! $('#privacy').prop('checked') ) { blnReturn = false; $('#lblprivacy').html( fHTMLErrore( "强制性验收。" ) ); $( ".fg-privacy" ).addClass( "has-error" ); } // Controllo Email if ( $('#txtEmail').val() != '' ) { $('#loader-email').removeClass('hide'); $('#lbltxtEmail').html( '' ); var intErrore = ''; $.ajax({ type: "POST", async: false, dataType: "json", url: "/tpl/default/assets/ajax/checkEmail.php", data: "action=checkEmail&pstrEmail=" + $("#txtEmail").val(), success: function(data){ intErrore = data.errore; if ( intErrore == 1 ) { // ERRORE : email NON corretta blnReturn = false; $('#lbltxtEmail').html( fHTMLErrore( "该地址不正确。" ) ); $( ".fg-txtEmail" ).addClass( "has-error" ); } if ( data.status == 'errore' ) blnSaved = false; else if ( data.status == 'ok' ) blnSaved = true; else swal("Oops!", "出问题了。", "error"); }, error: function(data){swal("Oops!", "出问题了。", "error");} }); } if ( blnLavoro ) { $('.luogolavoro_input').each(function() { var index = ( $(this).attr('name') ).replace( 'luogolavoro_', '' ); if ( $('#luogolavoro_'+index).val() == '' || $('#periodolavoro_'+index).val() == '' ) { blnReturn = false; $('#lblluogolavoro_'+index).html( fHTMLErrore( "输入地点和日期" ) ); $( '.fg-luogolavoro_'+index+' fg-periodolavoro_'+index ).addClass( "has-error" ); } }); $('.spostamento_select').each(function() { if ( $(this).val() != '' ) { var index = ( $(this).attr('name') ).replace( 'cmbSpostamentoCosa_', '' ); if ( $('#spostamentoda_'+index).val() == '' || $('#spostamentoa_'+index).val() == '' ) { blnReturn = false; $('#lblspostamento_'+index).html( fHTMLErrore( "输入地点" ) ); $( '.fg-spostamento_da_'+index+' fg-spostamento_a_'+index ).addClass( "has-error" ); } } }); $('.prenotazione_input').each(function() { var index = ( $(this).attr('name') ).replace( 'prenotazionedata_', '' ); if ( $('#prenotazionedove_'+index).val() == '' || ! parseInt( $('#prenotazionepersone_'+index).val() ) ) { blnReturn = false; $('#lblprenotazione_'+index).html( fHTMLErrore( "输入地点和人数" ) ); $( '.fg-prenotazione_dove_'+index+' fg-prenotazione_persone_'+index ).addClass( "has-error" ); } }); } else { $('.periodo_input').each(function() { var index = ( $(this).attr('name') ).replace( 'periodo_', '' ); if ( ( $('#luogo_'+index).val() == '' && $('#luogoaltro_'+index).val() == '' ) || $('#periodo_'+index).val() == '' ) { blnReturn = false; $('#lblluogo_'+index).html( fHTMLErrore( "输入地点和日期" ) ); $( '.fg-luogo_'+index+' fg-periodo_'+index ).addClass( "has-error" ); } }); var bambini = parseInt( $('#intBambini').val() ); if ( bambini > 0 ) { for ( i = 0; i < bambini; i++ ) { if ( $('#eta_bambino_'+i).val() == '' ) { blnReturn = false; $('#lbleta_box').html( fHTMLErrore( "输入孩子的年龄" ) ); $( '.fg-eta' ).addClass( "has-error" ); } } } var bambini_handicap = parseInt( $('#intBambiniHandicap').val() ); if ( bambini_handicap > 0 ) { for ( i = 0; i < bambini_handicap; i++ ) { if ( $('#eta_bambino_handicap_'+i).val() == '' ) { blnReturn = false; $('#lbleta_box_handicap').html( fHTMLErrore( "输入孩子的年龄" ) ); $( '.fg-eta_handicap' ).addClass( "has-error" ); } } } } if ( ! blnReturn ) { $('#submitLoad').addClass('hide'); $('#submitBut').removeClass('hide'); } $('#loader-email').addClass('hide'); return blnReturn; } function fHTMLErrore( pstr ) { return '' + pstr + ''; }