1$.validator.setDefaults({ ignore: ":hidden:not(.fxt-captcha)" }); 2 3/** 4 * Google Recaptcha 5 */ 6var reCaptchaArray = reCaptchaArray || []; 7$.validator.unobtrusive.adapters.add("recaptcha", function (options) { 8 options.rules["recaptcha"] = true; 9 if (options.message) { 10 options.messages["recaptcha"] = options.message; 11 } 12}); 13 14$.validator.addMethod("recaptcha", function (value, element, exclude) { 15 return true; 16}); 17var recaptchasRendered = false; 18var loadReCaptchas = function () { 19 for (var i = 0; i < reCaptchaArray.length; i++) { 20 var reCaptcha = reCaptchaArray[i]; 21 if (reCaptcha.IsRendered === undefined) { 22 reCaptcha.IsRendered = true; 23 reCaptcha(); 24 } 25 } 26}; 27 28/** 29 * File upload Content Type 30 */ 31$.validator.unobtrusive.adapters.addSingleVal("contenttype", "allowedcontenttypes"); 32 33$.validator.addMethod("contenttype", function (value, element, allowedcontenttypes) { 34 if (!this.optional(element)) { 35 for (var i = 0; i < element.files.length; i++) { 36 if (allowedcontenttypes.indexOf(element.files[i].type) < 0) { 37 return false; 38 } 39 } 40 } 41 return true; 42}); 43 44/** 45 * File upload File Size 46 */ 47$.validator.unobtrusive.adapters.addSingleVal("filesize", "maxfilesize"); 48$.validator.addMethod("filesize", function (value, element, maxfilesize) { 49 if (!this.optional(element)) { 50 for (var i = 0; i < element.files.length; i++) { 51 if (element.files[i].size > maxfilesize) { 52 return false; 53 } 54 } 55 } 56 return true; 57}); 58 59// Date Time Span Validator 60["timespan", "tsminagedate", "tsfuturedate", "tspastdate"].forEach(validationType =>{ 61 $.validator.unobtrusive.adapters.add(validationType, ['min', 'max', 'unit'], function(options) { 62 options.rules[validationType] = [options.params.min, options.params.max, options.params.unit]; 63 options.messages[validationType] = options.message; 64 }); 65 66 $.validator.addMethod(validationType, function (value, element, params) { 67 if (!this.optional(element)) { 68 var unit = params[2]; 69 var minvalue = params[0]; 70 var maxvalue = params[1]; 71 72 var valueToValidate = 0; 73 74 switch (unit) { 75 case 'days': 76 valueToValidate = getDays(value); 77 break; 78 case 'months': 79 valueToValidate = getMonths(value); 80 break; 81 case 'years': 82 valueToValidate = getYears(value); 83 break; 84 } 85 86 var isValid = true; 87 88 if (typeof minvalue !== 'undefined' && valueToValidate < minvalue) 89 isValid = false; 90 91 if (typeof maxvalue !== 'undefined' && valueToValidate > maxvalue) 92 isValid = false; 93 94 return isValid; 95 } 96 return true; 97 }); 98}) 99 100/* 101$.validator.unobtrusive.adapters.add('timespan', ['min', 'max', 'unit'], function(options) { 102 options.rules['timespan'] = [options.params.min, options.params.max, options.params.unit]; 103 options.messages['timespan'] = options.message; 104}); 105 106$.validator.addMethod("timespan", timespanValidatorFunction);*/ 107 108function getDays(date) { 109 var today = new Date(); 110 return Math.floor((today - new Date(date)) / (1000 * 60 * 60 * 24)); 111} 112 113function getYears(date) { 114 var today = new Date(); 115 var diffYears = today.getFullYear() - new Date(date).getFullYear(); 116 var temp = today; 117 118 temp.setFullYear(temp.getFullYear() - diffYears); 119 120 if (new Date(date) > temp) 121 diffYears--; 122 123 return diffYears; 124} 125 126function getMonths(date) { 127 var today = new Date(); 128 var d = new Date(date); 129 130 return (today.getFullYear() - d.getFullYear()) * 12 + today.getMonth() - d.getMonth(); 131}
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.