PageSourceSearch

https://www.johnsoncontrols.pl/sitecore%20modules/Web/ExperienceForms/scripts/form.validate.js

js johnsoncontrols.pl collected 2026-10-07 15:46:56 UTC 5,003 bytes, 127 lines download raw bytes

1(function($) {
2    $.validator.defaults.escapeHtml = true;
3    var adapters = $.validator.unobtrusive.adapters;
4    adapters.fxbAddNumberVal = function (adapterName, attribute, ruleName) {
5        attribute = attribute || "val";
6        ruleName = ruleName || adapterName;
7        this.add(adapterName, [attribute], function(options) {
8                var attrVal = options.params[attribute];
9                if ((attrVal || attrVal === 0) && !isNaN(attrVal)) {
10                    options.rules[ruleName] = Number(attrVal);
11                }
12                if (options.message) {
13                    options.messages[ruleName] = options.message;
14                }
15            });
16    };
17
18    adapters.fxbAddMinMax = function(adapterName, minRuleName, maxRuleName, minAttribute, maxAttribute) {
19        minAttribute = minAttribute || "min";
20        maxAttribute = maxAttribute || "max";
21        this.add(adapterName, [minAttribute, maxAttribute], function(options) {
22                if (options.params[minAttribute] && options.params[maxAttribute]) {
23                    if (!options.rules.hasOwnProperty(minRuleName)) {
24                        if (options.message) {
25                            options.messages[minRuleName] = options.message;
26                        }
27                    }
28                    if (!options.rules.hasOwnProperty(maxRuleName)) {
29                        if (options.message) {
30                            options.messages[maxRuleName] = options.message;
31                        }
32                    }
33                }
34            });
35    };
36
37    adapters.addBool("ischecked", "required");
38
39    $.validator.addMethod(
40        "daterange",
41        function(value, element, params) {
42            return this.optional(element) || (value >= params.min && value <= params.max);
43        });
44
45    adapters.add(
46        "daterange",
47        ["min", "max"],
48        function(options) {
49            var params = {
50                min: options.params.min,
51                max: options.params.max
52            };
53            options.rules["daterange"] = params;
54            options.messages["daterange"] = options.message;
55        });
56
57    adapters.addSingleVal("filesize", "max");
58    $.validator.addMethod(
59        "filesize",
60        function (value, element, max) {
61            if (!this.optional(element)) {
62                for (var i = 0; i < element.files.length; i++) {
63                    if (element.files[i].size > max) {
64                        return false;
65                    }
66                }
67            }
68            return true;
69        });
70
71    adapters.addSingleVal("filecount", "max");
72    $.validator.addMethod(
73        "filecount",
74        function (value, element, max) {
75            if (!this.optional(element)) {
76                    if (element.files.length > max) {
77                        return false;
78                    }
79            }
80            return true;
81        });
82
83    adapters.addSingleVal("filetype", "allowedcontenttypes");
84    $.validator.addMethod(
85        "filetype",
86        function (value, element, allowedContentTypes) {
87            if (!this.optional(element)) {
88                var allowedContentTypesArray = allowedContentTypes.split(",").filter(function (s) {
89                    // Remove empty entries
90                    return s !== "";
91                });
92                if (allowedContentTypesArray.length) {
93                    for (var i = 0; i < element.files.length; i++) {
94                        var file = element.files[i];
95                        var isValid = false;
96                        for (var j = 0; j < allowedContentTypesArray.length; j++) {
97                            var allowedContentType = allowedContentTypesArray[j];
98                            if (allowedContentType.indexOf("/") !== -1) {
99                                // MIME type comparison if there is a slash "/"
100                                isValid = allowedContentType.toLowerCase() === file.type.toLowerCase();
101                            } else {
102                                // File extension comparison
103                                isValid = allowedContentType.toLowerCase() === "." + file.name.split(".").pop().toLowerCase();
104                            }
105
106                            if (isValid) {
107                                break;
108                            }
109                        }
110
111                        if (!isValid) {
112                            return false;
113                        }
114                    }
115                }
116            }
117            return true;
118        });
119
120    adapters.fxbAddNumberVal("min");
121    adapters.fxbAddNumberVal("max");
122    adapters.fxbAddNumberVal("step");
123
124    adapters.fxbAddMinMax("range", "min", "max");
125    adapters.fxbAddMinMax("length", "minlength", "maxlength");
126    adapters.fxbAddMinMax("daterange", "min", "max");
127})(jQuery);

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.