1jQuery.validator.addMethod("alphanumericspace", function (value, element) { 2 return this.optional(element) || /^[a-zA-Z0-9\u0027-\u0027 -]*$/.test(value); 3}, "Letter, numbers and spaces only please"); 4 5jQuery.validator.addMethod("mcname", function (value, element) { 6 return this.optional(element) || /^[a-zA-Z0-9\u0027-\u0027 -]*$/.test(value); 7}, "Letter, numbers and spaces only please"); 8 9jQuery.validator.addMethod("mcaddress", function (value, element) { 10 return this.optional(element) || /^[a-zA-Z0-9 .]*$/.test(value); 11}, "Letter, numbers and spaces only please"); 12 13jQuery.validator.addMethod("mccity", function (value, element) { 14 return this.optional(element) || /^[a-zA-Z0-9\u0027-\u0027 .-]*$/.test(value); 15}, "Letter, numbers and spaces only please"); 16 17jQuery.validator.addMethod("birthdate", function (value, element) { 18 var birthmonth = parseInt(jQuery("#edit-birthmonth").val(), 10); 19 var birthday = parseInt(jQuery("#edit-birthday").val(), 10); 20 var birthyear = parseInt(jQuery("#edit-birthyear").val(), 10); 21 var birthdate = new Date(birthyear, birthmonth - 1, birthday); 22 return this.optional(element) || (!/Invalid|NaN/.test(birthdate.toString()) && (birthdate.getMonth() === (birthmonth - 1))); 23}, Drupal.t("Please enter a valid date of birth.")); 24 25jQuery.validator.addMethod("maxallowed", function (value, element) { 26 var birthmonth = parseInt(jQuery("#edit-birthmonth").val(), 10); 27 var birthday = parseInt(jQuery("#edit-birthday").val(), 10); 28 var birthyear = parseInt(jQuery("#edit-birthyear").val(), 10); 29 var today = new Date(); 30 var maxage = new Date(today.getFullYear() - 120, today.getMonth(), today.getDate()); 31 var birthdate = new Date(birthyear, birthmonth - 1, birthday); 32 return birthdate > maxage; 33},Drupal.t("Please enter a valid date of birth.")); 34 35jQuery.validator.addMethod("phone", function (value, element) { 36 var phone = jQuery("#edit-phoneareacode").val() + jQuery("#edit-phoneprefix").val() + jQuery("#edit-phonesuffix").val(); 37 return (jQuery.trim(phone).length == 0) || (jQuery.trim(phone).length == 10); 38}, "Please enter a valid phone."); 39 40jQuery.validator.addMethod("zipcode", function(value, element) { 41 42 return this.optional(element) || /^[0-9]*$/.test(value); 43}, Drupal.t("Please enter a valid zip code.")); 44 45jQuery.validator.addMethod("legaldrinkingage", function (value, element) { 46 var birthmonth = parseInt(jQuery("#edit-birthmonth").val(), 10); 47 var birthday = parseInt(jQuery("#edit-birthday").val(), 10); 48 var birthyear = parseInt(jQuery("#edit-birthyear").val(), 10); 49 var today = new Date(); 50 var drinkingage = new Date(today.getFullYear() - 21, today.getMonth(), today.getDate()); 51 var birthdate = new Date(birthyear, birthmonth - 1, birthday); 52 var legaldrinkingage = false; 53 if (birthdate > drinkingage) { 54 jQuery("#BirthDatePopover").css('display', 'block'); 55 legaldrinkingage = false; 56 } else { 57 jQuery("#BirthDatePopover").css('display', 'none'); 58 legaldrinkingage = true; 59 } 60 return legaldrinkingage; 61}, Drupal.t("You must be of legal drinking age")); 62 63jQuery.validator.addMethod("requireddesktop", function (value, element, param) { 64 // check if desktop 65 if (!jQuery.browser.mobile) { 66 // check if dependency is met 67 if (!this.depend(param, element)) { 68 return "dependency-mismatch"; 69 } 70 if (element.nodeName.toLowerCase() === "select") { 71 // could be an array for select-multiple or a string, both are fine this way 72 var val = jQuery(element).val(); 73 return val && val.length > 0; 74 } 75 if (this.checkable(element)) { 76 return this.getLength(value, element) > 0; 77 } 78 return jQuery.trim(value).length > 0; 79 } 80}, Drupal.t("This field is required.")); 81 82jQuery.validator.addClassRules({ 83 alphanumericspace: { alphanumericspace: true }, 84 mcname: { mcname: true }, 85 mcaddress: { mcaddress: true }, 86 mccity: { mccity: true }, 87 requireddesktop: { requireddesktop: true }, 88 birthdate: { birthdate: true }, 89 legaldrinkingage: { legaldrinkingage: true }, 90 phone: { phone: true }, 91 maxallowed: { maxallowed: true } 92}); 93
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.