function validateEmail(email){ var emailReg = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i); var valid = emailReg.test(email); if(!valid) { return false; } else { return true; } } $("#formstatic2").hide(); //document.getElementById("button1").disabled = true; //$('#button1').prop('disabled', true); $('#button1').prop('disabled', false); function enableBtn(){ //document.getElementById("button1").disabled = false; $('#button1').prop('disabled', false); } $().ready(function() { // Disable the checkbox by default $("input[name='agreement']").prop('disabled', true); // Enable the checkbox only when the phone field has exactly 10 numeric characters $('#phone').on('input', function() { var phoneValue = $.trim($(this).val()); // Get trimmed value of phone field var numericPhone = phoneValue.replace(/-/g, ''); // Remove all dashes var isValidPhone = numericPhone.length === 10 && /^\d+$/.test(numericPhone); // Check length and numeric values if (isValidPhone) { $("input[name='agreement']").prop('disabled', false); // Enable checkbox } else { $("input[name='agreement']").prop('disabled', true).prop('checked', false); // Disable and uncheck checkbox } }); $("#search_go").click(function(){ $("#sitesearch").submit(); }); var max1 = "17,00"; var max2 = "16,00"; //TIME const timepicker = $( '.js__timepicker' ).pickatime({ clear: '', min: [10,30], max: [18,30] }); //END TIME //DATE //$( '.js__datepicker' ).pickadate(); $('#reason').on('change', function() { $( '#date' ).pickadate('picker').clear(); }); $('#name,#text,#email').on('keypress',function(){ if($(this).val().length > 0){ $(this).removeClass('error'); } }); $('#date,#time').on('change',function(){ if($(this).val().length > 0){ $(this).removeClass('error'); } }); $(".submit").click(function () { var email = $.trim($("#email").val()); var name = $("#name").val(); var text = $("#text").val(); var date2 = $("#date").val(); var time2 = $("#time").val(); if(!$.trim(name).length) { $("#name").addClass("error"); $("#name").focus(); return false; } else if(!$.trim(text).length) { $("#name").removeClass("error"); $("#text").addClass("error"); $("#text").focus(); return false; } else if(!$.trim(date2).length) { $("#text").removeClass("error"); $("#date").addClass("error"); $("#date").focus(); return false; } else if(!$.trim(time2).length) { $("#date").removeClass("error"); $("#time").addClass("error"); $("#time").focus(); return false; } else if(validateEmail(email)) { $("#time").removeClass("error"); //$('form#contactus').submit(); //alert("success"); } else { $("#email").addClass("error"); $("#email").val(''); $("#email").focus(); return false; } }); $('#phone').mask('000-000-0000', {clearIfNotMatch: true}); $( '.js__datepicker' ).pickadate({ disable: [ 1, [2000, 1, 1], [2025, 6, 7] ], onSet:function(context){ var d = new Date(context.select); var isSat = d.getDay() == 6; var isMon = d.getDay() == 1; var isWed = d.getDay() == 3; var isFri = d.getDay() == 5; var max = isSat ? [14,30] : isMon ? [17,30] : isWed ? [17,30] : isFri ? [17,30] : [18,30]; var time3 = timepicker.pickatime('picker'); //time3.clear().set({max}); time3.clear().set('max',max); }, min: true, max: 180, format: 'dddd mmmm d', formatSubmit: 'mm/dd/yyyy' }), picker_get__disable = $input_get__disable.pickadate( 'picker' ); //END DATE });