jQuery.noConflict(); jQuery(document).ready(function($) { $('a.show_privacy').colorbox({ width: '50%', inline:true, href:'#privacytext' }); $('#richiedi-generico').click(function (e) { e.preventDefault(); var form = $('form#richiesta-generica'); if (validateRichiestaPreventivo(form)) { // send ga track var struttura = $('#sl3').val(); if ( !struttura ) struttura = ""; ga( 'send', 'event', 'richiesta_preventivo', 'click', 'Richiesta preventivo ' + struttura ); form.submit(); } }); jQuery('input#fromdatebig').datepicker({ dateFormat: 'dd/mm/yy', minDate: 0, defaultDate: 0, //showOn: 'both', //buttonImage: "/pw/images/calendar.png", //set the class 'week-highlight' for the whole week beforeShowDay: function(date){ var day = date.getDay(); return [true,( day == 0)?"sunday":( day == 6)?"saturday":'']; }, onSelect: function( selectedDate ) { var instance = jQuery(this).data("datepicker"); jQuery.datepicker.parseDate(instance.settings.dateFormat , selectedDate, instance.settings); var date2 = jQuery(this).datepicker('getDate', '+1d'); var date3 = jQuery(this).datepicker('getDate', '+1d'); date2.setDate(date2.getDate()+1); jQuery('input#todatebig').datepicker( "option", "minDate", date2); date3.setDate(date3.getDate()+7); jQuery('input#todatebig').datepicker('setDate',date2); } }); jQuery('input#todatebig').datepicker({ dateFormat: 'dd/mm/yy', minDate: +1, defaultDate: +1, //showOn: 'both', //buttonImage: "/pw/images/calendar.png", //set the class 'week-highlight' for the whole week beforeShowDay: function(date){ var day = date.getDay(); return [true,( day == 0)?"sunday":( day == 6)?"saturday":'']; }, onSelect: function( selectedDate ) { var instance = jQuery(this).data("datepicker"); jQuery.datepicker.parseDate(instance.settings.dateFormat ,selectedDate, instance.settings ); } }); jQuery('#ui-datepicker-div').css('clip', 'auto'); jQuery('#ui-datepicker-div').css('height', 'auto'); function isNumber(n) { return !isNaN(parseFloat(n)) && isFinite(n); } function validateRichiestaPreventivo(form) { var mail=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i; var fromdatebig = form.find('input#fromdatebig').val(); if (!fromdatebig || fromdatebig == '') { alert('Inserisci una data valida'); form.find('input#fromdatebig').focus(); return false; } var nomebig = form.find('input#nomebig').val(); if (!nomebig || nomebig == '') { alert('Inserisci un nome valido'); form.find('input#nomebig').focus(); return false; } var cognomebig = form.find('input#cognomebig').val(); if (!cognomebig || cognomebig == '') { alert('Inserisci un cognome valido'); form.find('input#cognomebig').focus(); return false; } var emailbig = form.find('input#emailbig').val(); if (!emailbig || emailbig == '' || !mail.test(emailbig)) { alert('Inserisci una email valida'); form.find('input#emailbig').focus(); return false; } var nadulti = form.find('input#paxbig').val(); if (!nadulti || nadulti == '' || !isNumber(nadulti)) { alert('Inserisci il numero di adulti'); form.find('input#paxbig').focus(); return false; } var nbambini = form.find('input#bimbibig').val(); var etabambini = form.find('input#etabimbibig').val(); if (isNumber(nbambini) && nbambini > 0 && etabambini == '') { alert('Inserisci l\'età dei bambini separate da virgola'); form.find('input#etabimbibig').focus(); return false; } var privacybig = form.find('input#privacybig:checked').val(); if (!privacybig) { alert('Per proseguire è necessario accettare le condizioni sulla privacy'); form.find('input#privacybig').focus(); return false; } return true; } });