1jQuery(document).ready(function(){ 2 3 function creditCardTypeFromNumber(num) { 4 num = num.replace(/[^\d]/g,''); 5 if (num.match(/^5[1-5]\d{14}$/) || num.match(/^(5[1-5]|(2221[0-9]{2}|222[2-9][0-9]{2}|22[3-9][0-9]{3}|2[3-6][0-9]{4}|27[0-1][0-9]{3}|2720[0-9]{2}))/)) { 6 return 'MasterCard'; 7 } else if (num.match(/^4\d{15}/) || num.match(/^4\d{12}/)) { 8 return 'Visa'; 9 } else if (num.match(/^3[47]\d{13}/)) { 10 return 'AmEx'; 11 } else if (num.match(/^6011\d{12}/)) { 12 return 'Discover'; 13 } else if (num.match(/^35\d{14}$/)) { // JCB (16 digits) 14 return 'JCB'; 15 } 16 return 'UNKNOWN'; 17 } 18 19 jQuery.validator.addMethod("noHtmlTags", function (value, element) { 20 var regex = /<[^>]*>/; 21 return !regex.test(value); 22 }, "HTML tags are not allowed."); 23 24 jQuery.validator.addMethod("noSpecialChars", function (value, element) { 25 var regex = /[^a-zA-Z\s]/; 26 return !regex.test(value); 27 }, "Special characters are not allowed."); 28 29 jQuery.validator.addMethod("expiryDate", function(value, element, options) { 30 var month = jQuery('#expiry_month').val(); 31 var year = jQuery('#expiry_year').val(); 32 33 if (month.length !== 2 || year.length !== 4) { 34 return false; 35 } 36 37 var expiryMonth = parseInt(month, 10); 38 var expiryYear = parseInt(year, 10); 39 40 var currentDate = new Date(); 41 var currentMonth = currentDate.getMonth() + 1; // JavaScript months are 0-11 42 var currentYear = currentDate.getFullYear(); 43 44 if (expiryMonth < 1 || expiryMonth > 12) { 45 return false; 46 } 47 48 if (expiryYear < currentYear) { 49 return false; 50 } 51 52 if (expiryYear === currentYear && expiryMonth < currentMonth) { 53 return false; 54 } 55 56 return true; 57 }, "Please enter a valid expiry date."); 58 59 jQuery.validator.addMethod("creditCard", function(value, element) { 60 value = value.replace(/\D/g, ""); // Remove non-digit characters 61 // Basic Luhn check for valid card numbers 62 var sum = 0; 63 var shouldDouble = false; 64 for (var i = value.length - 1; i >= 0; i--) { 65 var digit = parseInt(value.charAt(i)); 66 if (shouldDouble) { 67 digit *= 2; 68 if (digit > 9) { 69 digit -= 9; 70 } 71 } 72 sum += digit; 73 shouldDouble = !shouldDouble; 74 } 75 return (sum % 10) === 0; 76 }, "Please enter a valid card number"); 77 78 //jQuery("#cust_num").focus(); 79 jQuery("#card-payment").validate({ 80 rules: { 81 card_holder_name: { 82 required: true, 83 minlength: 2, 84 maxlength: 100, 85 noHtmlTags: true, 86 noSpecialChars: true, 87 }, 88 card_number: { 89 required: true, 90 maxlength: 19, 91 creditCard:true, 92 }, 93 expiry_year: { 94 required: true, 95 expiryDate: true, 96 }, 97 cvv: { 98 required: true, 99 minlength: 3, 100 maxlength: 4, 101 }, 102 }, 103 messages: { 104 card_holder_name: { 105 required: "Please enter name on card", 106 minlength: "Name must be at least 2 characters", 107 maxlength: "Name must be at most 100 characters", 108 noHtmlTags: "Please enter valid name.", 109 noSpecialChars: "Please enter valid name.", 110 }, 111 card_number: { 112 required: "Please enter your card number", 113 creditCard: "Please enter valid card number", 114 }, 115 expiry_year: { 116 required: "Please enter expiry date", 117 expiryDate: "Please enter valid expiry date", 118 }, 119 cvv: { 120 required: "Please enter CVV", 121 minlength: "CVV must be at least 3 digits", 122 maxlength: "CVV must be at most 4 digits" 123 }, 124 }, 125 errorPlacement: function(error, element) { 126 if (element.attr("name") == "expiry_year") { 127 error.insertAfter(element.parent()); 128 } else { 129 error.insertAfter(element); 130 } 131 }, 132 }); 133 134 jQuery('#cvv').on("contextmenu",function(e){ 135 return false;
136 }); 137 138 var hostname = jQuery(location).attr('hostname'); 139 140 jQuery('#card_number').blur(function() { 141 card_type = creditCardTypeFromNumber(jQuery(this).val()); 142 if(card_type == "Visa"){ 143 jQuery(".card_img").attr("src",'https://' + hostname + '/wp-content/themes/tsd/images/visa_card.png'); 144 } else if(card_type == "MasterCard") { 145 jQuery(".card_img").attr("src",'https://' + hostname + '/wp-content/themes/tsd/images/master_card.png'); 146 } else if(card_type == "AmEx") { 147 jQuery(".card_img").attr("src",'https://' + hostname + '/wp-content/themes/tsd/images/american-express.png'); 148 } else if(card_type == "JCB") { 149 jQuery(".card_img").attr("src",'https://' + hostname + '/wp-content/themes/tsd/images/jcb.png'); 150 } else { 151 jQuery(".card_img").attr("src",'https://' + hostname + '/wp-content/themes/tsd/images/credit-card.png'); 152 } 153 }); 154 155 jQuery(".allow_only_numbers").on("keypress keyup blur",function (event) { 156 jQuery(this).val(jQuery(this).val().replace(/[^\d].+/, "")); 157 if ((event.which < 48 || event.which > 57) && (event.which != 0 && event.which != 8)) { 158 event.preventDefault(); 159 } 160 }); 161 162 jQuery('#Step5_Prev').click(function() { 163 jQuery('.tour-stpe-5, .shed-booking-progress-item.step-5').removeClass('active'); 164 jQuery('.tour-stpe-4, .shed-booking-progress-item.step-4').addClass('active'); 165 sessionStorage.setItem('form_step', '4'); 166 }); 167 168 jQuery('#card-payment #submit').click(function() { 169 if (jQuery("#card-payment").valid()) { 170 jQuery(".loading_wrap").show(); 171 jQuery(document).on('keydown.esc keydown.enter', function(e) { 172 if (e.key === "Escape") { 173 e.preventDefault(); 174 } else if (e.key === "Enter") { 175 e.preventDefault(); 176 } 177 }); 178 } 179 }); 180 181 jQuery(document).on('keydown.esc keydown.enter', function(e) { 182 if (e.key === "Escape") { 183 e.preventDefault(); 184 } else if (e.key === "Enter") { 185 e.preventDefault(); 186 } 187 }); 188 189}); 190 191jQuery(window).load(function() { 192 jQuery(".loading_wrap").hide(); 193}); 194
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.