function afterSiteLoad(){ var currdate = new Date(); var dd=currdate.getDate(); currdate.setDate(dd+1); var currDateStr = currdate.getDate()+"/"+(currdate.getMonth()+1)+"/"+currdate.getFullYear(); var currdateFLT = new Date(); var dd=currdateFLT.getDate(); var daysToAdd=1; if(currdateFLT.getDay()==5) daysToAdd=3; else if(currdateFLT.getDay()==6) daysToAdd=2; currdateFLT.setDate(currdateFLT.getDate() + daysToAdd); var currDateStrFLT = currdateFLT.getDate()+"/"+(currdateFLT.getMonth()+1)+"/"+currdateFLT.getFullYear(); $.validator.addMethod("onlyLatin", function(value, element) { re = new RegExp('[^a-zA-Z]+'); return this.optional(element) || !re.test(value); }, jQuery.validator.messages.onlyLatin ); $.validator.addClassRules("onlyLatin", { onlyLatin: true}); $.validator.addClassRules("creditcard", { creditcard: true}); $.validator.addMethod("TimeFormat", function(value, element) { re = new RegExp('^([0-1][0-9]|2[0-3])[:][0-5][0-9]$'); return this.optional(element) || re.test(value); }, jQuery.validator.messages.TimeFormat); $.validator.addClassRules("TimeFormat", { TimeFormat: true}); $.validator.addMethod("dateEL", function(value, element, param) { // make sure it is in the expected format if (value.search(/^\d{1,2}[\/|\-|\.|_]\d{1,2}[\/|\-|\.|_]\d{2,4}/g) != 0) return false; // remove other separators that are not valid with the Date class value = value.replace(/[\-|\.|_]/g, "/"); var arrDateParts = value.split("/"); var year = arrDateParts[2]; if(year.length==2){ year = "20"+ arrDateParts[2]; } //put month in front s = arrDateParts[1] + "/" + arrDateParts[0] + "/" + year; // convert it into a date instance var dt = new Date(Date.parse(s)); // check the components of the date // since Date instance automatically rolls over each component arrDateParts = s.split("/"); return ( dt.getMonth() == arrDateParts[0]-1 && dt.getDate() == arrDateParts[1] && dt.getFullYear() == year ); }, "Please enter a date in the format dd/mm/yyyy"); $.validator.addClassRules("dateEL", { dateEL: true}); $.validator.addMethod("futureDate", function(value, element) { value = value.replace(/[\-|\.|_]/g, "/"); var arrDateParts = value.split("/"); //put month in front var year = arrDateParts[2]; if(year.length==2){ year = "20"+ arrDateParts[2]; } s = arrDateParts[1] + "/" + arrDateParts[0] + "/" +year; // convert it into a date instance var serviceDate = new Date(Date.parse(s)); return currdate < serviceDate ; }, jQuery.validator.messages.futureDate); $.validator.addClassRules("ValidDate", {dateEL: true, futureDate: currDateStr}); $.validator.addMethod("futureDateFLT", function(value, element) { value = value.replace(/[\-|\.|_]/g, "/"); var arrDateParts = value.split("/"); //put month in front var year = arrDateParts[2]; if(year.length==2){ year = "20"+ arrDateParts[2]; } s = arrDateParts[1] + "/" + arrDateParts[0] + "/" +year; // convert it into a date instance var serviceDate = new Date(Date.parse(s)); return currdateFLT < serviceDate ; }, jQuery.validator.messages.futureDate); $.validator.addClassRules("ValidDateFLT", {dateEL: true, futureDateFLT: currDateStrFLT}); jQuery.validator.addMethod("greaterThan", function(value, element, params) { value = value.replace(/[\-|\.|_]/g, "/"); var arrDateParts = value.split("/"); //put month in front var year = arrDateParts[2]; if(year.length==2){ year = "20"+ arrDateParts[2]; } s = arrDateParts[1] + "/" + arrDateParts[0] + "/" +year; // convert it into a date instance var serviceDate = new Date(Date.parse(s)); var startValue = $(params).val(); var StartDateParts = startValue.split("/"); //put month in front var Startyear = StartDateParts[2]; if(Startyear && Startyear.length==2){ Startyear = "20"+ StartDateParts[2]; } startDateStr = StartDateParts[1] + "/" + StartDateParts[0] + "/" +Startyear; var StartDate = new Date(Date.parse(startDateStr)); return serviceDate >= StartDate; },jQuery.validator.messages.afterDate); $.validator.addClassRules("EndDate", {dateEL: true, greaterThan: ".StartDate"}); $.validator.addMethod("repeatEmail", function(value, element, params) { var startValue = $(params).val(); return value==startValue; }, jQuery.validator.messages.repeatEmail ); $.validator.addClassRules("repeatEmail", {repeatEmail: ".email"}); $.validator.addMethod("notGreek", function(value, element) { re = new RegExp('.*[α-ωΑ-Ω]+.*'); return (this.optional(element) && value == "") || !re.test(value); }, jQuery.validator.messages.notGreek ); //This validation is based on PnrdMethods.checkValidityBeforeBooking $.validator.addMethod("invalidName", function(value, element) { return (value != "Adult" && value != "ADULT" && value != "adult" && value != "Child" && value != "child" && value != "CHILD" && value != "Infant" && value != "INFANT" && value != "infant"); }, jQuery.validator.messages.invalidName ); $.validator.addMethod("onlyGreek", function(value, element) { re = new RegExp('[^α-ωΑ-Ω ]+'); return this.optional(element) || !re.test(value); }, jQuery.validator.messages.onlyGreek ); $.validator.addClassRules("notGreek", { notGreek: true}); $.validator.addClassRules("onlyGreek", { onlyGreek: true}); $.validator.addMethod("passwordCheck", function(value, element) { re = new RegExp('[^0-9a-zA-Z !@#\$\^\*\(\)]+'); return this.optional(element) || !re.test(value); }, jQuery.validator.messages.passwordCheck ); $.validator.addClassRules("passwordCheck", { passwordCheck: true , minlength: 5}); $.validator.addClassRules("cvv2", { digits:true ,maxlength: 4}); $.validator.addClassRules("name", {minlength: 2}); } String.format = function( text ) { //check if there are two arguments in the arguments list if ( arguments.length <= 1 ) { //if there are not 2 or more arguments there’s nothing to replace //just return the original text return text; } //decrement to move to the second argument in the array var tokenCount = arguments.length - 2; for( var token = 0; token <= tokenCount; token++ ) { //iterate through the tokens and replace their placeholders from the original text in order text = text.replace( new RegExp( "\\{" + token + "\\}", "gi" ), arguments[ token + 1 ] ); } return text; }; /* function doLogin(){ if ($("#frmLogin").valid()) { $("#frmLogin #submit").click(); return true; } else { return false; } } */ function goToAnchor( positionElement){ var button_ = $('#'+positionElement); var offset = button_.offset(); window.scroll(0,offset.top); } function doFullTextSearch(){ if (trim($("#terms").val()) == "") { return false; } else { return true; } } function doNewsletterSubscription(){ if ($("#frmNewsletter").valid()) { $("#frmNewsletter #submit").click(); } else { return false; } } function trim(str) { return str.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); } function validateCustomers(){ if ($("#customersForm").valid()) { document.forms["customersForm"].submit(); } } function validateHotelCriteria(){ if ($("#hotelform").valid()) { document.forms["hotelform"].submit(); } } function validateHotelCriteria2(){ if ($("#specific_hotel_form").valid()) { document.forms["specific_hotel_form"].submit(); } } function validateFlightCriteria(){ if ($("#flightform").valid()) { document.forms["flightform"].submit(); } } function validateTransferCriteria(){ if ($("#transferform").valid()) { document.forms["transferform"].submit(); } } function validateCruiseCriteria(){ if ($("#cruiseform").valid()) { document.forms["cruiseform"].submit(); } } function validateCruiseCriteria2(){ if ($("#specific_cruise_form").valid()) { document.forms["specific_cruise_form"].submit(); } } function validatePackageCriteria(){ if ($("#packageform").valid()) { document.forms["packageform"].submit(); } } function validateCarCriteria(){ if ($("#carform").valid()) { document.forms["carform"].submit(); } } function validateExcursionCriteria(){ if ($("#excursionform").valid()) { document.forms["excursionform"].submit(); } } function validatePayment(){ var msg ='Please Wait...'; if ($("#frmPaymentProtection_Details").valid()) { $.blockUI({ message: '

'+msg+'

'}); $('#pay_button').click(); } }