PageSourceSearch

https://baaps.org.uk/_resources/js/master/validation.v20240226100839.js

js baaps.org.uk collected 2026-10-02 17:10:22 UTC 6,950 bytes, 183 lines download raw bytes

1function validateInt(input, args) { }
2function validateDecimal(input, args) { }
3function validateDate(input, args) { }
4function validateCheckBox(sender, args) { }
5function validateFile(sender, args) { }
6function validateCategories(sender, args) { }
7
8extraJQueryFunctions.push(function ($) {
9    // Extend .Net validation javascript to allow adding and removing bootstrap error classes from a control when an associated validator fails
10    if (typeof (Page_ClientValidate) != "undefined") {
11        AspValidatorUpdateDisplay = ValidatorUpdateDisplay;
12        AspValidatorValidate = ValidatorValidate;
13
14        ValidatorUpdateDisplay = function (val) {
15            AspValidatorUpdateDisplay(val);
16
17            if ((typeof (val.enabled) == "undefined" || val.enabled != false) && IsValidationGroupMatch(val, AspValidatorValidating)) {
18                if ($("#" + val.controltovalidate).parents(".form-group").length > 0) {
19
20                    var formGroup = $("#" + val.controltovalidate).parents(".form-group").first();
21
22                    var currentType = "unknown";
23
24                    var allTypes = [
25                        {
26                            evalFunction: RequiredFieldValidatorEvaluateIsValid,
27                            type: "required-field"
28                        },
29                        {
30                            evalFunction: RegularExpressionValidatorEvaluateIsValid,
31                            type: "regex-field"
32                        },
33                        {
34                            evalFunction: RangeValidatorEvaluateIsValid,
35                            type: "range-field"
36                        },
37                        {
38                            evalFunction: CustomValidatorEvaluateIsValid,
39                            type: "custom-field"
40                        },
41                        {
42                            evalFunction: CompareValidatorEvaluateIsValid,
43                            type: "compare-field"
44                        }
45                    ];
46
47                    for (var i = 0; i < allTypes.length; i++) {
48                        if (val.evaluationfunction == allTypes[i].evalFunction) {
49                            currentType = allTypes[i].type;
50                        }
51                    }
52
53                    if (val.isvalid) {
54                        formGroup.removeClass("has-error-" + currentType);
55                    } else {
56                        formGroup.addClass("has-error has-feedback has-error-" + currentType);
57                    }
58
59                    var anyErrorsFound = false;
60
61                    for (var a = 0; a < allTypes.length; a++) {
62                        if (formGroup.hasClass("has-error-" + allTypes[a].type)) {
63                            anyErrorsFound = true;
64                        }
65                    }
66
67                    if (!anyErrorsFound) {
68                        formGroup.removeClass("has-error has-feedback");
69                    }
70                }
71            }
72        };
73
74        ValidatorValidate = function (val, validationGroup, event) {
75            AspValidatorValidating = validationGroup;
76            AspValidatorValidate(val, validationGroup, event);
77        };
78    }
79
80    validateInt = function (input, args) {
81        if (/^\-?\d+$/ig.exec(document.getElementById(input.controltovalidate).value) == null) {
82            args.IsValid = false;
83        }
84    };
85
86    validateDecimal = function (input, args) {
87        if (/^\-?\d+(\.\d+)?$/ig.exec(document.getElementById(input.controltovalidate).value) == null) {
88            args.IsValid = false;
89        }
90    };
91
92    validateDate = function (input, args) {
93        if (/^[0-3]?\d\/((0?[1-9])|(1[0-2]))\/\d{2,4}(\s(([01]?[0-9])|(2[0-4])):(([0-5][0-9])|(60)))?$/ig.exec(document.getElementById(input.controltovalidate).value) == null) {
94            args.IsValid = false;
95        }
96    };
97
98    validateCheckBox = function (sender, args) {
99        var id = sender.getAttribute('ControlToValidate') ?? sender.dataset.controlToValidate;
100        var checkBox = document.getElementById(id);
101        if (!checkBox.checked) {
102            args.IsValid = false;
103        }
104    }
105
106    validateFile = function (sender, args) {
107        var textBox = $("#" + sender.controltovalidate);
108        var filePath = textBox.val();
109
110        if (filePath == "") {
111            args.isValid = true;
112            return;
113        }
114
115        var fileName = filePath.split("/").pop();
116
117        var errorMessage = "";
118
119        var fileExtension = "." + fileName.split(".").pop();
120
121        var acceptedFileExtensions = textBox.data("acceptedFileExtensions");
122        if (acceptedFileExtensions.indexOf(',') >= 0) {
123            acceptedFileExtensions = acceptedFileExtensions.split(',')
124        }
125
126        var acceptedFileExtensionsString = "";
127
128        for (var i = 0; i < acceptedFileExtensions.length; i++) {
129            acceptedFileExtensionsString += acceptedFileExtensions[i];
130
131            if (i < (acceptedFileExtensions.length - 1)) {
132                acceptedFileExtensionsString += ", ";
133            }
134        }
135
136        var inWhiteList = false;
137
138        for (var a = 0; a < acceptedFileExtensions.length; a++) {
139            if (fileExtension == acceptedFileExtensions[a]) {
140                inWhiteList = true;
141            }
142        }
143
144        if (!inWhiteList) {
145            errorMessage = "Sorry, your file was of the wrong type, please choose a file with the following extensions: '" + acceptedFileExtensionsString + "'.";
146        }
147
148        if (errorMessage != "") {
149            args.IsValid = false;
150            sender.errormessage = errorMessage;
151            sender.innerHTML = "<span class='help-block'>" + errorMessage + "</span>";
152        }
153
154        var updateInfoFunc = textBox.data("updateInfo");
155        if (updateInfoFunc) {
156            updateInfoFunc();
157        }
158    };
159
160    validateCategories = function (sender, args) {
161        var validator = $(sender);
162        var min = parseInt(validator.data('min'));
163        var max = parseInt(validator.data('max'));
164
165        if (!isNaN(min) || !isNaN(max)) {
166            var checkboxesContainer = validator.siblings('.checkboxes');
167            if (checkboxesContainer.length <= 0) {
168                checkboxesContainer = validator.siblings('.category_selector').find('.checkboxes');
169            }
170
171            if (checkboxesContainer.length > 0) {
172                var checkedCount = checkboxesContainer.find('input[type="checkbox"]:checked').length;
173
174                if (!isNaN(min) && checkedCount < min) {
175                    args.IsValid = false;
176                }
177                else if (!isNaN(max) && checkedCount > max) {
178                    args.IsValid = false;
179                }
180            }
181        }
182    }
183});

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.