django-forms-frontend-validation 1.0.0__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- django_forms_frontend_validation-1.0.0.dist-info/LICENSE +21 -0
- django_forms_frontend_validation-1.0.0.dist-info/METADATA +86 -0
- django_forms_frontend_validation-1.0.0.dist-info/RECORD +28 -0
- django_forms_frontend_validation-1.0.0.dist-info/WHEEL +5 -0
- django_forms_frontend_validation-1.0.0.dist-info/top_level.txt +1 -0
- formvalidator/__init__.py +0 -0
- formvalidator/admin.py +3 -0
- formvalidator/apps.py +6 -0
- formvalidator/form_utils/__init__.py +1 -0
- formvalidator/form_utils/form_utils.py +21 -0
- formvalidator/forms.py +9 -0
- formvalidator/migrations/__init__.py +0 -0
- formvalidator/models.py +3 -0
- formvalidator/settings.py +14 -0
- formvalidator/static/dist/forms.bundle.js +216 -0
- formvalidator/static/webpack/package-lock.json +2869 -0
- formvalidator/static/webpack/package.json +19 -0
- formvalidator/static/webpack/src/css/style.css +42 -0
- formvalidator/static/webpack/src/js/formFunctions.js +263 -0
- formvalidator/static/webpack/src/js/index.js +2 -0
- formvalidator/static/webpack/webpack.config.js +23 -0
- formvalidator/templates/base.html +26 -0
- formvalidator/templates/formvalidator/sample.html +51 -0
- formvalidator/templates/formvalidator/sample2.html +51 -0
- formvalidator/templates/includes/header.html +18 -0
- formvalidator/tests.py +21 -0
- formvalidator/urls.py +12 -0
- formvalidator/views.py +54 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024-Present Andrew Kyle
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,86 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: django-forms-frontend-validation
|
3
|
+
Version: 1.0.0
|
4
|
+
Summary: A Django app for front-end form validation
|
5
|
+
Home-page: https://github.com/andrew-kyle92/django-frontend-validation
|
6
|
+
Author: Andrew Kyle
|
7
|
+
Author-email: andrew.kyle92@yahoo.com
|
8
|
+
License: MIT
|
9
|
+
Classifier: Framework :: Django
|
10
|
+
Classifier: Programming Language :: Python
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
12
|
+
Description-Content-Type: text/markdown
|
13
|
+
License-File: LICENSE
|
14
|
+
Requires-Dist: Django>=3.2
|
15
|
+
|
16
|
+
# django-forms-frontend-validation App
|
17
|
+
___
|
18
|
+
|
19
|
+
This project provides a comprehensive system for handling and validating HTML forms in Django applications. It combines client-side JavaScript-based validation and server-side Python logic for robust form processing.
|
20
|
+
|
21
|
+
The application is designed to streamline the process of form validation, ensuring user inputs meet the requirements before submitting them to the server. The system offers features like automatic required-field validation, error handling, and dynamic CSRF token management for secure data transmission.
|
22
|
+
|
23
|
+
## Features
|
24
|
+
- Client-Side Validation:
|
25
|
+
- Automatically validates required fields.
|
26
|
+
- Displays validation errors inline and dynamically updates them upon correction.
|
27
|
+
- Adds asterisks to labels of required fields for better user clarity.
|
28
|
+
- Server-Side Settings:
|
29
|
+
- Control which forms and fields to ignore during validation.
|
30
|
+
- Define validation behavior, such as enforcing checks only on form submission.
|
31
|
+
- Integration with Django Settings:
|
32
|
+
- Use Django's settings to dynamically configure validation rules.
|
33
|
+
- Secure Fetch Calls:
|
34
|
+
- Includes CSRF token management for secure AJAX-based form submissions.
|
35
|
+
|
36
|
+
## Usage
|
37
|
+
### Setting Up
|
38
|
+
1. Include Required Components:
|
39
|
+
- Include the JavaScript files in your project to enable client-side functionality.
|
40
|
+
- Ensure `form_utils.py` is imported and accessible in your Django app.
|
41
|
+
2. Define Settings in settings.py
|
42
|
+
- Add `formvalidator` to installed apps.
|
43
|
+
```python
|
44
|
+
INSTALLED_APPS = [
|
45
|
+
...,
|
46
|
+
'formvalidator',
|
47
|
+
]
|
48
|
+
```
|
49
|
+
- Configure the following variables to customize the behavior.
|
50
|
+
```python
|
51
|
+
IGNORED_CLASSES = ['example-class', 'example-class-2', ...]
|
52
|
+
IGNORE_VALIDATION = ['example-ignore-validation', ...]
|
53
|
+
VALIDATE_ONLY_ON_SUBMIT = ['all'] # Options: "__all__", specific class names, or leave empty.
|
54
|
+
```
|
55
|
+
3. Initial Forms:
|
56
|
+
- Ensure the `_InitializeForms` method is called during page load to attach validation logic to forms dynamically.
|
57
|
+
To your HTML template with the form, add this.
|
58
|
+
```html
|
59
|
+
<script>
|
60
|
+
// fv (formsvalidator) is exported from forms.bundle.js
|
61
|
+
window.addEventListener("load", () => {
|
62
|
+
let ignoredClasses = {{ form_validator.ignored_classes|safe }}; // add more classes that represent forms you want this script to ignore.
|
63
|
+
let ignoreValidation = {{ form_validator.ignore_validation|safe }}; // add any form classes that you want to ignore validation
|
64
|
+
let validateOnlyOnSubmit = {{ form_validator.validate_only_on_submit|safe }}; // for hitting all forms make index 0 either __all__, all, * or leave blank for false or use false
|
65
|
+
let forms = document.getElementsByTagName("form");
|
66
|
+
// if (form || userForm) {
|
67
|
+
if (forms.length > 0) {
|
68
|
+
// calling specific functions on all forms
|
69
|
+
fv._InitializeForms(forms, ignoredClasses, ignoreValidation, validateOnlyOnSubmit);
|
70
|
+
}
|
71
|
+
});
|
72
|
+
</script>
|
73
|
+
```
|
74
|
+
4. Server-Side Context:
|
75
|
+
- Use the `FormsValidator` class to pass configuration to templates:
|
76
|
+
```python
|
77
|
+
from formvalidator.form_utils import FormsValidator
|
78
|
+
|
79
|
+
|
80
|
+
def my_view(request):
|
81
|
+
form_validator = FormsValidator()
|
82
|
+
context = {
|
83
|
+
'form_validator': form_validator.get_context(),
|
84
|
+
}
|
85
|
+
return render(request, 'my_template.html', context)
|
86
|
+
```
|
@@ -0,0 +1,28 @@
|
|
1
|
+
formvalidator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
formvalidator/admin.py,sha256=suMo4x8I3JBxAFBVIdE-5qnqZ6JAZV0FESABHOSc-vg,63
|
3
|
+
formvalidator/apps.py,sha256=3C-Kq3f9oo1nB2RMXXC0jqYEYYV0MYkVg2nI1GIJE3Y,158
|
4
|
+
formvalidator/forms.py,sha256=PSOiyrwDN_5XuX-f9l8ZAQozZwNo5PhZCRTAKl_Jlig,775
|
5
|
+
formvalidator/models.py,sha256=Vjc0p2XbAPgE6HyTF6vll98A4eDhA5AvaQqsc4kQ9AQ,57
|
6
|
+
formvalidator/settings.py,sha256=5ZckcudXktsLXdYykJ0q2EzgNQuaJ2_Mn95ZDWgPK94,712
|
7
|
+
formvalidator/tests.py,sha256=jq5sY8A7Pe0VQ-j33gRJTRgBf-BPu4I6Z2sND68EP8A,842
|
8
|
+
formvalidator/urls.py,sha256=Y2NSQC0IzLEHU4HqNhx_8DnQhScV9D8Ssbc8WGueTMA,301
|
9
|
+
formvalidator/views.py,sha256=TYqBRjnpKccQZA-Dwajp0heJ7-rhEkHetkGqSd12cJs,1391
|
10
|
+
formvalidator/form_utils/__init__.py,sha256=joyuThQtBJ08qadN5rntReKcCRWsonBgy95qKkuaW2E,40
|
11
|
+
formvalidator/form_utils/form_utils.py,sha256=3LzlfAhgd7jkw9KKKJ1YsrTiJgRVKZwIlqgA3A6p-10,698
|
12
|
+
formvalidator/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
|
+
formvalidator/static/dist/forms.bundle.js,sha256=duXcJCPOSg7U8RcO82rUBd6JSHf8UKQENWRYBKP3BlA,34808
|
14
|
+
formvalidator/static/webpack/package-lock.json,sha256=2efugRXwEqLTV-MIyRezE4XfoldXBPjxEdZcZj0cpH8,111553
|
15
|
+
formvalidator/static/webpack/package.json,sha256=KdvnQsQ2L1D6j7fMzXAAup7TbZAWQqXgQ-jTJKvkNfM,382
|
16
|
+
formvalidator/static/webpack/webpack.config.js,sha256=1VNt5YvappvIfng4QH6SYpGPsYbGirO4Yu4sTiqpagA,543
|
17
|
+
formvalidator/static/webpack/src/css/style.css,sha256=k0nLJjqK63fGlhalKs_-RKgsu9szFIzygvIis4hQTVg,536
|
18
|
+
formvalidator/static/webpack/src/js/formFunctions.js,sha256=SRCfCnENiCSQmoXPGPclIYBsItcQP6qvVPy5w1lCS_E,9095
|
19
|
+
formvalidator/static/webpack/src/js/index.js,sha256=RZ2f421UJuRHoO9kXQ5RDLfb4EYjebnHEvLxOFfKhJk,53
|
20
|
+
formvalidator/templates/base.html,sha256=husejzZpyn7DKk-3S6frsalTMz4-ZO5EV5GWobWWEvc,888
|
21
|
+
formvalidator/templates/formvalidator/sample.html,sha256=IKklx25wt-paXmfaMbSZfTZaWFzlq_BGMOuVKACNpyI,2048
|
22
|
+
formvalidator/templates/formvalidator/sample2.html,sha256=_E5Rtv4fWOut5dbpRsguoEUw-X_Hln6wok4g2KPlzCo,2129
|
23
|
+
formvalidator/templates/includes/header.html,sha256=5EWbHxj-JFu7fzmGUWWqOxoG2bwl03UwwUG_O68qzj0,946
|
24
|
+
django_forms_frontend_validation-1.0.0.dist-info/LICENSE,sha256=gA3cqug2Eqh9zkbcEDQ1Ez1APddDnmbX6bO6_wcBRM8,1095
|
25
|
+
django_forms_frontend_validation-1.0.0.dist-info/METADATA,sha256=0KN4s4cGTZHdzW56lDm55rZeimg-krGDaLFPllc5Src,3876
|
26
|
+
django_forms_frontend_validation-1.0.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
27
|
+
django_forms_frontend_validation-1.0.0.dist-info/top_level.txt,sha256=E9SLf9Mg8MAqnCin_sgh__XTquz_st_-Qyy9w3-3fms,14
|
28
|
+
django_forms_frontend_validation-1.0.0.dist-info/RECORD,,
|
@@ -0,0 +1 @@
|
|
1
|
+
formvalidator
|
File without changes
|
formvalidator/admin.py
ADDED
formvalidator/apps.py
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
from .form_utils import FormsValidator
|
@@ -0,0 +1,21 @@
|
|
1
|
+
from django.conf import settings
|
2
|
+
|
3
|
+
|
4
|
+
class FormsValidator:
|
5
|
+
"""
|
6
|
+
Provides access to settings for ignored classes and validation behavior.
|
7
|
+
"""
|
8
|
+
def __init__(self):
|
9
|
+
self.ignored_classes = settings.IGNORED_CLASSES
|
10
|
+
self.ignore_validation = settings.IGNORE_VALIDATION
|
11
|
+
self.validate_only_on_submit = settings.VALIDATE_ONLY_ON_SUBMIT
|
12
|
+
|
13
|
+
def get_context(self):
|
14
|
+
"""
|
15
|
+
Returns a dictionary for use in template contexts
|
16
|
+
"""
|
17
|
+
return {
|
18
|
+
'ignored_classes': self.ignored_classes,
|
19
|
+
'ignore_validation': self.ignore_validation,
|
20
|
+
'validate_only_on_submit': self.validate_only_on_submit
|
21
|
+
}
|
formvalidator/forms.py
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
from django import forms
|
2
|
+
|
3
|
+
|
4
|
+
class SampleForm(forms.Form):
|
5
|
+
first_name = forms.CharField(label='First Name', max_length=100, required=True, widget=forms.TextInput(attrs={'class': 'form-control'}))
|
6
|
+
last_name = forms.CharField(label='Last Name', max_length=100, required=True, widget=forms.TextInput(attrs={'class': 'form-control'}))
|
7
|
+
email = forms.EmailField(label='Email', max_length=100, required=True, widget=forms.TextInput(attrs={'class': 'form-control'}))
|
8
|
+
phone = forms.CharField(label='Phone Number', max_length=100, required=False, widget=forms.TextInput(attrs={'class': 'form-control'}))
|
9
|
+
address = forms.CharField(label='Address', max_length=100, required=False, widget=forms.Textarea(attrs={'class': 'form-control', 'rows': 5, 'cols': 50}))
|
File without changes
|
formvalidator/models.py
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# ##### Form Configs #####
|
2
|
+
# A list of HTML classes of forms you want to ignore, completely
|
3
|
+
IGNORED_CLASSES = []
|
4
|
+
|
5
|
+
# Ignoring validation doesn't automatically assume you're omitting the form from being
|
6
|
+
# the form submittal process. It literally just means you would like to ignore all validation.
|
7
|
+
IGNORE_VALIDATION = [] + IGNORED_CLASSES
|
8
|
+
|
9
|
+
# A list of classes where the validation is done only after the submit button has been clicked.
|
10
|
+
# the types can be boolean, string, or list
|
11
|
+
# the string keyword options are 'all', '__all__', '*'
|
12
|
+
# if you would like to keep the type as an array, but still want to hit all forms, you can just set
|
13
|
+
# index 0 as one of those keywords
|
14
|
+
VALIDATE_ONLY_ON_SUBMIT = ["*"]
|
@@ -0,0 +1,216 @@
|
|
1
|
+
/*
|
2
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
3
|
+
* This devtool is neither made for production nor for readable output files.
|
4
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
5
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
6
|
+
* or disable the default devtool with "devtool: false".
|
7
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
8
|
+
*/
|
9
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
10
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
11
|
+
module.exports = factory();
|
12
|
+
else if(typeof define === 'function' && define.amd)
|
13
|
+
define([], factory);
|
14
|
+
else if(typeof exports === 'object')
|
15
|
+
exports["fv"] = factory();
|
16
|
+
else
|
17
|
+
root["fv"] = factory();
|
18
|
+
})(this, () => {
|
19
|
+
return /******/ (() => { // webpackBootstrap
|
20
|
+
/******/ "use strict";
|
21
|
+
/******/ var __webpack_modules__ = ({
|
22
|
+
|
23
|
+
/***/ "./node_modules/css-loader/dist/cjs.js!./src/css/style.css":
|
24
|
+
/*!*****************************************************************!*\
|
25
|
+
!*** ./node_modules/css-loader/dist/cjs.js!./src/css/style.css ***!
|
26
|
+
\*****************************************************************/
|
27
|
+
/***/ ((module, __webpack_exports__, __webpack_require__) => {
|
28
|
+
|
29
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../node_modules/css-loader/dist/runtime/noSourceMaps.js */ \"./node_modules/css-loader/dist/runtime/noSourceMaps.js\");\n/* harmony import */ var _node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../node_modules/css-loader/dist/runtime/api.js */ \"./node_modules/css-loader/dist/runtime/api.js\");\n/* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);\n// Imports\n\n\nvar ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));\n// Module\n___CSS_LOADER_EXPORT___.push([module.id, `/****** Forms ******/\r\ninput, select {\r\n font-size: 18px!important;\r\n}\r\n\r\n.errorlist li, .error-msg {\r\n color: red;\r\n}\r\n\r\n.error {\r\n color: red;\r\n font-style: italic;\r\n}\r\n\r\n.error-input {\r\n background: #edbabf;\r\n border-color: #dc3545;\r\n}\r\n\r\n.error-msg {\r\n color: #dc3545;\r\n margin-bottom: 0;\r\n}\r\n\r\n.success {\r\n color: blue;\r\n}\r\n\r\n.readonly {\r\n background-color: #e9ecef;\r\n opacity: 1;\r\n cursor: not-allowed;\r\n}\r\n\r\n.required-field {\r\n font-weight: 800;\r\n}\r\n\r\n.required-field::after {\r\n content: \" *\";\r\n color: red;\r\n}`, \"\"]);\n// Exports\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);\n\n\n//# sourceURL=webpack://fv/./src/css/style.css?./node_modules/css-loader/dist/cjs.js");
|
30
|
+
|
31
|
+
/***/ }),
|
32
|
+
|
33
|
+
/***/ "./node_modules/css-loader/dist/runtime/api.js":
|
34
|
+
/*!*****************************************************!*\
|
35
|
+
!*** ./node_modules/css-loader/dist/runtime/api.js ***!
|
36
|
+
\*****************************************************/
|
37
|
+
/***/ ((module) => {
|
38
|
+
|
39
|
+
eval("\n\n/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n Author Tobias Koppers @sokra\n*/\nmodule.exports = function (cssWithMappingToString) {\n var list = [];\n\n // return the list of modules as css string\n list.toString = function toString() {\n return this.map(function (item) {\n var content = \"\";\n var needLayer = typeof item[5] !== \"undefined\";\n if (item[4]) {\n content += \"@supports (\".concat(item[4], \") {\");\n }\n if (item[2]) {\n content += \"@media \".concat(item[2], \" {\");\n }\n if (needLayer) {\n content += \"@layer\".concat(item[5].length > 0 ? \" \".concat(item[5]) : \"\", \" {\");\n }\n content += cssWithMappingToString(item);\n if (needLayer) {\n content += \"}\";\n }\n if (item[2]) {\n content += \"}\";\n }\n if (item[4]) {\n content += \"}\";\n }\n return content;\n }).join(\"\");\n };\n\n // import a list of modules into the list\n list.i = function i(modules, media, dedupe, supports, layer) {\n if (typeof modules === \"string\") {\n modules = [[null, modules, undefined]];\n }\n var alreadyImportedModules = {};\n if (dedupe) {\n for (var k = 0; k < this.length; k++) {\n var id = this[k][0];\n if (id != null) {\n alreadyImportedModules[id] = true;\n }\n }\n }\n for (var _k = 0; _k < modules.length; _k++) {\n var item = [].concat(modules[_k]);\n if (dedupe && alreadyImportedModules[item[0]]) {\n continue;\n }\n if (typeof layer !== \"undefined\") {\n if (typeof item[5] === \"undefined\") {\n item[5] = layer;\n } else {\n item[1] = \"@layer\".concat(item[5].length > 0 ? \" \".concat(item[5]) : \"\", \" {\").concat(item[1], \"}\");\n item[5] = layer;\n }\n }\n if (media) {\n if (!item[2]) {\n item[2] = media;\n } else {\n item[1] = \"@media \".concat(item[2], \" {\").concat(item[1], \"}\");\n item[2] = media;\n }\n }\n if (supports) {\n if (!item[4]) {\n item[4] = \"\".concat(supports);\n } else {\n item[1] = \"@supports (\".concat(item[4], \") {\").concat(item[1], \"}\");\n item[4] = supports;\n }\n }\n list.push(item);\n }\n };\n return list;\n};\n\n//# sourceURL=webpack://fv/./node_modules/css-loader/dist/runtime/api.js?");
|
40
|
+
|
41
|
+
/***/ }),
|
42
|
+
|
43
|
+
/***/ "./node_modules/css-loader/dist/runtime/noSourceMaps.js":
|
44
|
+
/*!**************************************************************!*\
|
45
|
+
!*** ./node_modules/css-loader/dist/runtime/noSourceMaps.js ***!
|
46
|
+
\**************************************************************/
|
47
|
+
/***/ ((module) => {
|
48
|
+
|
49
|
+
eval("\n\nmodule.exports = function (i) {\n return i[1];\n};\n\n//# sourceURL=webpack://fv/./node_modules/css-loader/dist/runtime/noSourceMaps.js?");
|
50
|
+
|
51
|
+
/***/ }),
|
52
|
+
|
53
|
+
/***/ "./src/css/style.css":
|
54
|
+
/*!***************************!*\
|
55
|
+
!*** ./src/css/style.css ***!
|
56
|
+
\***************************/
|
57
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
58
|
+
|
59
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! !../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js */ \"./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js\");\n/* harmony import */ var _node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _node_modules_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! !../../node_modules/style-loader/dist/runtime/styleDomAPI.js */ \"./node_modules/style-loader/dist/runtime/styleDomAPI.js\");\n/* harmony import */ var _node_modules_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _node_modules_style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! !../../node_modules/style-loader/dist/runtime/insertBySelector.js */ \"./node_modules/style-loader/dist/runtime/insertBySelector.js\");\n/* harmony import */ var _node_modules_style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_node_modules_style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _node_modules_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! !../../node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js */ \"./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js\");\n/* harmony import */ var _node_modules_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_node_modules_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _node_modules_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! !../../node_modules/style-loader/dist/runtime/insertStyleElement.js */ \"./node_modules/style-loader/dist/runtime/insertStyleElement.js\");\n/* harmony import */ var _node_modules_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_node_modules_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var _node_modules_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! !../../node_modules/style-loader/dist/runtime/styleTagTransform.js */ \"./node_modules/style-loader/dist/runtime/styleTagTransform.js\");\n/* harmony import */ var _node_modules_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_node_modules_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5__);\n/* harmony import */ var _node_modules_css_loader_dist_cjs_js_style_css__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! !!../../node_modules/css-loader/dist/cjs.js!./style.css */ \"./node_modules/css-loader/dist/cjs.js!./src/css/style.css\");\n\n \n \n \n \n \n \n \n \n \n\nvar options = {};\n\noptions.styleTagTransform = (_node_modules_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default());\noptions.setAttributes = (_node_modules_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default());\noptions.insert = _node_modules_style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default().bind(null, \"head\");\noptions.domAPI = (_node_modules_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default());\noptions.insertStyleElement = (_node_modules_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default());\n\nvar update = _node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default()(_node_modules_css_loader_dist_cjs_js_style_css__WEBPACK_IMPORTED_MODULE_6__[\"default\"], options);\n\n\n\n\n /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_node_modules_css_loader_dist_cjs_js_style_css__WEBPACK_IMPORTED_MODULE_6__[\"default\"] && _node_modules_css_loader_dist_cjs_js_style_css__WEBPACK_IMPORTED_MODULE_6__[\"default\"].locals ? _node_modules_css_loader_dist_cjs_js_style_css__WEBPACK_IMPORTED_MODULE_6__[\"default\"].locals : undefined);\n\n\n//# sourceURL=webpack://fv/./src/css/style.css?");
|
60
|
+
|
61
|
+
/***/ }),
|
62
|
+
|
63
|
+
/***/ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js":
|
64
|
+
/*!****************************************************************************!*\
|
65
|
+
!*** ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***!
|
66
|
+
\****************************************************************************/
|
67
|
+
/***/ ((module) => {
|
68
|
+
|
69
|
+
eval("\n\nvar stylesInDOM = [];\nfunction getIndexByIdentifier(identifier) {\n var result = -1;\n for (var i = 0; i < stylesInDOM.length; i++) {\n if (stylesInDOM[i].identifier === identifier) {\n result = i;\n break;\n }\n }\n return result;\n}\nfunction modulesToDom(list, options) {\n var idCountMap = {};\n var identifiers = [];\n for (var i = 0; i < list.length; i++) {\n var item = list[i];\n var id = options.base ? item[0] + options.base : item[0];\n var count = idCountMap[id] || 0;\n var identifier = \"\".concat(id, \" \").concat(count);\n idCountMap[id] = count + 1;\n var indexByIdentifier = getIndexByIdentifier(identifier);\n var obj = {\n css: item[1],\n media: item[2],\n sourceMap: item[3],\n supports: item[4],\n layer: item[5]\n };\n if (indexByIdentifier !== -1) {\n stylesInDOM[indexByIdentifier].references++;\n stylesInDOM[indexByIdentifier].updater(obj);\n } else {\n var updater = addElementStyle(obj, options);\n options.byIndex = i;\n stylesInDOM.splice(i, 0, {\n identifier: identifier,\n updater: updater,\n references: 1\n });\n }\n identifiers.push(identifier);\n }\n return identifiers;\n}\nfunction addElementStyle(obj, options) {\n var api = options.domAPI(options);\n api.update(obj);\n var updater = function updater(newObj) {\n if (newObj) {\n if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {\n return;\n }\n api.update(obj = newObj);\n } else {\n api.remove();\n }\n };\n return updater;\n}\nmodule.exports = function (list, options) {\n options = options || {};\n list = list || [];\n var lastIdentifiers = modulesToDom(list, options);\n return function update(newList) {\n newList = newList || [];\n for (var i = 0; i < lastIdentifiers.length; i++) {\n var identifier = lastIdentifiers[i];\n var index = getIndexByIdentifier(identifier);\n stylesInDOM[index].references--;\n }\n var newLastIdentifiers = modulesToDom(newList, options);\n for (var _i = 0; _i < lastIdentifiers.length; _i++) {\n var _identifier = lastIdentifiers[_i];\n var _index = getIndexByIdentifier(_identifier);\n if (stylesInDOM[_index].references === 0) {\n stylesInDOM[_index].updater();\n stylesInDOM.splice(_index, 1);\n }\n }\n lastIdentifiers = newLastIdentifiers;\n };\n};\n\n//# sourceURL=webpack://fv/./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js?");
|
70
|
+
|
71
|
+
/***/ }),
|
72
|
+
|
73
|
+
/***/ "./node_modules/style-loader/dist/runtime/insertBySelector.js":
|
74
|
+
/*!********************************************************************!*\
|
75
|
+
!*** ./node_modules/style-loader/dist/runtime/insertBySelector.js ***!
|
76
|
+
\********************************************************************/
|
77
|
+
/***/ ((module) => {
|
78
|
+
|
79
|
+
eval("\n\nvar memo = {};\n\n/* istanbul ignore next */\nfunction getTarget(target) {\n if (typeof memo[target] === \"undefined\") {\n var styleTarget = document.querySelector(target);\n\n // Special case to return head of iframe instead of iframe itself\n if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {\n try {\n // This will throw an exception if access to iframe is blocked\n // due to cross-origin restrictions\n styleTarget = styleTarget.contentDocument.head;\n } catch (e) {\n // istanbul ignore next\n styleTarget = null;\n }\n }\n memo[target] = styleTarget;\n }\n return memo[target];\n}\n\n/* istanbul ignore next */\nfunction insertBySelector(insert, style) {\n var target = getTarget(insert);\n if (!target) {\n throw new Error(\"Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.\");\n }\n target.appendChild(style);\n}\nmodule.exports = insertBySelector;\n\n//# sourceURL=webpack://fv/./node_modules/style-loader/dist/runtime/insertBySelector.js?");
|
80
|
+
|
81
|
+
/***/ }),
|
82
|
+
|
83
|
+
/***/ "./node_modules/style-loader/dist/runtime/insertStyleElement.js":
|
84
|
+
/*!**********************************************************************!*\
|
85
|
+
!*** ./node_modules/style-loader/dist/runtime/insertStyleElement.js ***!
|
86
|
+
\**********************************************************************/
|
87
|
+
/***/ ((module) => {
|
88
|
+
|
89
|
+
eval("\n\n/* istanbul ignore next */\nfunction insertStyleElement(options) {\n var element = document.createElement(\"style\");\n options.setAttributes(element, options.attributes);\n options.insert(element, options.options);\n return element;\n}\nmodule.exports = insertStyleElement;\n\n//# sourceURL=webpack://fv/./node_modules/style-loader/dist/runtime/insertStyleElement.js?");
|
90
|
+
|
91
|
+
/***/ }),
|
92
|
+
|
93
|
+
/***/ "./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js":
|
94
|
+
/*!**********************************************************************************!*\
|
95
|
+
!*** ./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js ***!
|
96
|
+
\**********************************************************************************/
|
97
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
98
|
+
|
99
|
+
eval("\n\n/* istanbul ignore next */\nfunction setAttributesWithoutAttributes(styleElement) {\n var nonce = true ? __webpack_require__.nc : 0;\n if (nonce) {\n styleElement.setAttribute(\"nonce\", nonce);\n }\n}\nmodule.exports = setAttributesWithoutAttributes;\n\n//# sourceURL=webpack://fv/./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js?");
|
100
|
+
|
101
|
+
/***/ }),
|
102
|
+
|
103
|
+
/***/ "./node_modules/style-loader/dist/runtime/styleDomAPI.js":
|
104
|
+
/*!***************************************************************!*\
|
105
|
+
!*** ./node_modules/style-loader/dist/runtime/styleDomAPI.js ***!
|
106
|
+
\***************************************************************/
|
107
|
+
/***/ ((module) => {
|
108
|
+
|
109
|
+
eval("\n\n/* istanbul ignore next */\nfunction apply(styleElement, options, obj) {\n var css = \"\";\n if (obj.supports) {\n css += \"@supports (\".concat(obj.supports, \") {\");\n }\n if (obj.media) {\n css += \"@media \".concat(obj.media, \" {\");\n }\n var needLayer = typeof obj.layer !== \"undefined\";\n if (needLayer) {\n css += \"@layer\".concat(obj.layer.length > 0 ? \" \".concat(obj.layer) : \"\", \" {\");\n }\n css += obj.css;\n if (needLayer) {\n css += \"}\";\n }\n if (obj.media) {\n css += \"}\";\n }\n if (obj.supports) {\n css += \"}\";\n }\n var sourceMap = obj.sourceMap;\n if (sourceMap && typeof btoa !== \"undefined\") {\n css += \"\\n/*# sourceMappingURL=data:application/json;base64,\".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), \" */\");\n }\n\n // For old IE\n /* istanbul ignore if */\n options.styleTagTransform(css, styleElement, options.options);\n}\nfunction removeStyleElement(styleElement) {\n // istanbul ignore if\n if (styleElement.parentNode === null) {\n return false;\n }\n styleElement.parentNode.removeChild(styleElement);\n}\n\n/* istanbul ignore next */\nfunction domAPI(options) {\n if (typeof document === \"undefined\") {\n return {\n update: function update() {},\n remove: function remove() {}\n };\n }\n var styleElement = options.insertStyleElement(options);\n return {\n update: function update(obj) {\n apply(styleElement, options, obj);\n },\n remove: function remove() {\n removeStyleElement(styleElement);\n }\n };\n}\nmodule.exports = domAPI;\n\n//# sourceURL=webpack://fv/./node_modules/style-loader/dist/runtime/styleDomAPI.js?");
|
110
|
+
|
111
|
+
/***/ }),
|
112
|
+
|
113
|
+
/***/ "./node_modules/style-loader/dist/runtime/styleTagTransform.js":
|
114
|
+
/*!*********************************************************************!*\
|
115
|
+
!*** ./node_modules/style-loader/dist/runtime/styleTagTransform.js ***!
|
116
|
+
\*********************************************************************/
|
117
|
+
/***/ ((module) => {
|
118
|
+
|
119
|
+
eval("\n\n/* istanbul ignore next */\nfunction styleTagTransform(css, styleElement) {\n if (styleElement.styleSheet) {\n styleElement.styleSheet.cssText = css;\n } else {\n while (styleElement.firstChild) {\n styleElement.removeChild(styleElement.firstChild);\n }\n styleElement.appendChild(document.createTextNode(css));\n }\n}\nmodule.exports = styleTagTransform;\n\n//# sourceURL=webpack://fv/./node_modules/style-loader/dist/runtime/styleTagTransform.js?");
|
120
|
+
|
121
|
+
/***/ }),
|
122
|
+
|
123
|
+
/***/ "./src/js/formFunctions.js":
|
124
|
+
/*!*********************************!*\
|
125
|
+
!*** ./src/js/formFunctions.js ***!
|
126
|
+
\*********************************/
|
127
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
128
|
+
|
129
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ _Initialize: () => (/* binding */ _Initialize),\n/* harmony export */ _InitializeForms: () => (/* binding */ _InitializeForms),\n/* harmony export */ checkForm: () => (/* binding */ checkForm),\n/* harmony export */ csrftoken: () => (/* binding */ csrftoken),\n/* harmony export */ fetchHandleForm: () => (/* binding */ fetchHandleForm)\n/* harmony export */ });\n// ########## Getting the csrf token for the fetch calls ##########\r\nfunction getCookie(name) {\r\n let cookieValue = null;\r\n if (document.cookie && document.cookie !== '') {\r\n const cookies = document.cookie.split(';');\r\n for (let i = 0; i < cookies.length; i++) {\r\n const cookie = cookies[i].trim();\r\n // Does this cookie string begin with the name we want?\r\n if (cookie.substring(0, name.length + 1) === (name + '=')) {\r\n cookieValue = decodeURIComponent(cookie.substring(name.length + 1));\r\n break;\r\n }\r\n }\r\n }\r\n return cookieValue;\r\n}\r\nconst csrftoken = getCookie('csrftoken');\r\n\r\n// ##### Fetch Calls #####\r\n// performs fetch call to view\r\nconst fetchHandleForm = async (form) => {\r\n let formData = new FormData(form);\r\n return await fetch(form.action, {\r\n method: \"POST\",\r\n credentials: \"same-origin\",\r\n headers: {\r\n // \"Accept\": \"m\",\r\n // \"X-Requested-With\": \"XMLHttpRequest\",\r\n \"X-CSRFToken\": csrftoken,\r\n },\r\n body: formData,\r\n }).then(async (response) => {\r\n return response.json();\r\n });\r\n}\r\n// ***** Adding asterisks to labels of required inputs *****\r\nfunction addAsterisks(form) {\r\n // gathering all inputs\r\n let formGroups = document.querySelectorAll(`#${form.id} .form-group`);\r\n let inputs = getRequiredFields(formGroups);\r\n\r\n // adding the required-field class which will add the asterisk\r\n for (let i = 0; i < inputs.length; i++) {\r\n let label = document.querySelector(`label[for=${inputs[i].name}]`);\r\n if (inputs[i].required) {\r\n label.classList.add(\"required-field\");\r\n }\r\n }\r\n}\r\n\r\n// In-line validation on required fields\r\nfunction validateInputs(form) {\r\n // gathering all inputs\r\n let formGroups = document.querySelectorAll(`#${form.id} .form-group`);\r\n let inputs = getRequiredFields(formGroups);\r\n\r\n // adding listeners to each input for validation\r\n for (let i = 0; i < inputs.length; i++) {\r\n inputs[i].addEventListener(\"focusout\", () => {\r\n if (inputs[i].value === \"\" || inputs[i].value === null) {\r\n addError(inputs[i]);\r\n } else {\r\n removeError(inputs[i]);\r\n }\r\n });\r\n }\r\n}\r\n// validateInputs();\r\n\r\n// check form function\r\nfunction checkForm(form) {\r\n let errors = false;\r\n\r\n // gathering all inputs\r\n let formGroups = document.querySelectorAll(`#${form.id} .form-group`);\r\n let inputs = getRequiredFields(formGroups);\r\n\r\n // iterating through all required fields to check for invalidation\r\n for (let i = 0; i < inputs.length; i++) {\r\n let input = inputs[i];\r\n if (input.value === \"\" || !input.value) {\r\n addError(input);\r\n errors = true;\r\n }\r\n }\r\n\r\n return errors\r\n}\r\n\r\n// submit button validation check\r\nfunction submitValidation(form) {\r\n form.form.addEventListener(\"submit\", (e) => {\r\n // preventing default submission behavior\r\n e.preventDefault();\r\n\r\n // gathering all inputs\r\n let f = e.target;\r\n // let formGroups = document.querySelectorAll(`#${form.id} .form-group`);\r\n // let inputs = getRequiredFields(formGroups);\r\n // // let form = document.getElementById(\"form\") !== null ? document.getElementById(\"form\") : document.getElementById(\"userForm\");\r\n let errors = checkForm(f);\r\n\r\n // submitting the form if there aren't any errors\r\n if (!errors) {\r\n form.form.submit();\r\n } else {\r\n let invalidInputs = document.getElementsByClassName(\"validation-error\");\r\n // scroll to the first invalid input\r\n invalidInputs[0].parentElement.scrollIntoView();\r\n }\r\n });\r\n}\r\n// submitValidation();\r\n\r\n// adds an error to an input\r\nfunction addError(input) {\r\n let inputParent = input.parentElement;\r\n if (!inputParent.className.includes(\"form-group\")){\r\n inputParent = input.parentElement.parentElement;\r\n }\r\n let errorAdded = inputParent.dataset.errorAdded;\r\n inputParent.classList.add(\"validation-error\");\r\n input.classList.add(\"error-input\")\r\n if (errorAdded === \"false\" || !errorAdded) {\r\n // creating the error message p\r\n let eP = document.createElement(\"p\");\r\n eP.setAttribute(\"class\", \"error-msg\");\r\n eP.innerText = \"This input is required\";\r\n inputParent.appendChild(eP);\r\n inputParent.dataset.errorAdded = \"true\";\r\n }\r\n}\r\n\r\n// removes the error from an input\r\nfunction removeError(input) {\r\n let inputParent = input.parentElement;\r\n if (!inputParent.className.includes(\"form-group\")){\r\n inputParent = input.parentElement.parentElement;\r\n }\r\n let errorAdded = inputParent.dataset.errorAdded;\r\n inputParent.classList.remove(\"validation-error\");\r\n input.classList.remove(\"error-input\");\r\n // removing the error message p\r\n if (errorAdded === \"true\") {\r\n inputParent.removeChild(inputParent.lastElementChild);\r\n inputParent.dataset.errorAdded = \"false\";\r\n }\r\n}\r\n\r\n// function to get all required input\r\nfunction getRequiredFields(formGroups) {\r\n let nameList = [\"SELECT\", \"INPUT\", \"TEXTAREA\"];\r\n let inputs = [];\r\n // let formGroups = document.getElementsByClassName(\"form-group\");\r\n for (let i = 0; i < formGroups.length; i++) {\r\n let children = formGroups[i].children;\r\n for (let j = 0; j < children.length; j++) {\r\n if (children[j].tagName === \"DIV\"){\r\n let grandChildren = children[j].children;\r\n for (let a = 0; a < grandChildren.length; a++) {\r\n if (nameList.includes(grandChildren[a].tagName)) {\r\n if (grandChildren[a].required) {\r\n inputs.push(grandChildren[a]);\r\n }\r\n }\r\n }\r\n }\r\n else{\r\n if (nameList.includes(children[j].tagName)) {\r\n if (children[j].required) {\r\n inputs.push(children[j]);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n return inputs\r\n}\r\n\r\n// checks if the form will be ignored form validation.\r\nfunction getIgnored(form, ignoredClasses) {\r\n let isIgnored = false;\r\n let classes = form.classList;\r\n if (ignoredClasses.length > 0) {\r\n classes.forEach((_class) => {\r\n if (ignoredClasses.includes(_class)) {\r\n isIgnored = true;\r\n return isIgnored;\r\n }\r\n });\r\n }\r\n return isIgnored\r\n}\r\n\r\n// Checks if the form will be validated.\r\nfunction isValidate(form, ignoredClasses) {\r\n let enableValidate = true;\r\n let classes = form.classList;\r\n if (ignoredClasses.length > 0) {\r\n classes.forEach((_class) => {\r\n if (ignoredClasses.includes(_class)) {\r\n enableValidate = false;\r\n return enableValidate;\r\n }\r\n });\r\n }\r\n return enableValidate\r\n}\r\n\r\n// Confirms if a form will only validate the form on submit, only.\r\nfunction getValidateOnlyValidateOnSubmit(form, validateOnlyOnSubmit, enableValidation) {\r\n let validateOnSubmit = false;\r\n let trueFlags = [\"all\", \"__all__\", \"*\", \"true\"];\r\n if (enableValidation) {\r\n let classes = form.classList;\r\n if (trueFlags.includes(validateOnlyOnSubmit[0])) {\r\n validateOnSubmit = true;\r\n return true;\r\n }\r\n else {\r\n classes.forEach((_class) => {\r\n if (validateOnlyOnSubmit.includes(_class)) {\r\n validateOnSubmit = true;\r\n return validateOnlyOnSubmit;\r\n }\r\n });\r\n }\r\n }\r\n return validateOnSubmit;\r\n}\r\n\r\n// adds listener logic to the form\r\nfunction _Initialize(form={}){\r\n if (!form.ignored || form.enableValidation) {\r\n // add all listeners to each form\r\n addAsterisks(form);\r\n if (!form.validateOnlyOnSubmit) {\r\n validateInputs(form);\r\n }\r\n if (!form.ignored) {\r\n submitValidation(form);\r\n }\r\n }\r\n}\r\n\r\n// function to initialize forms into a json object\r\nfunction _InitializeForms(formNodes, ignoredFormClasses=[], ignoredValidationClasses=[], validateOnlyOnSubmit){\r\n for (let i = 0; i < formNodes.length; i++) {\r\n let currentForm = formNodes[i];\r\n let ignored = getIgnored(currentForm, ignoredFormClasses);\r\n let enableValidation = isValidate(currentForm, ignoredValidationClasses);\r\n let validateOnSubmit = getValidateOnlyValidateOnSubmit(currentForm, validateOnlyOnSubmit, enableValidation);\r\n let _form = {\r\n id: currentForm.id,\r\n form: currentForm,\r\n ignored: ignored,\r\n enableValidation: enableValidation,\r\n validateOnlyOnSubmit: validateOnSubmit,\r\n }\r\n\r\n // adding form functionality\r\n _Initialize(_form);\r\n }\r\n}\n\n//# sourceURL=webpack://fv/./src/js/formFunctions.js?");
|
130
|
+
|
131
|
+
/***/ })
|
132
|
+
|
133
|
+
/******/ });
|
134
|
+
/************************************************************************/
|
135
|
+
/******/ // The module cache
|
136
|
+
/******/ var __webpack_module_cache__ = {};
|
137
|
+
/******/
|
138
|
+
/******/ // The require function
|
139
|
+
/******/ function __webpack_require__(moduleId) {
|
140
|
+
/******/ // Check if module is in cache
|
141
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
142
|
+
/******/ if (cachedModule !== undefined) {
|
143
|
+
/******/ return cachedModule.exports;
|
144
|
+
/******/ }
|
145
|
+
/******/ // Create a new module (and put it into the cache)
|
146
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
147
|
+
/******/ id: moduleId,
|
148
|
+
/******/ // no module.loaded needed
|
149
|
+
/******/ exports: {}
|
150
|
+
/******/ };
|
151
|
+
/******/
|
152
|
+
/******/ // Execute the module function
|
153
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
154
|
+
/******/
|
155
|
+
/******/ // Return the exports of the module
|
156
|
+
/******/ return module.exports;
|
157
|
+
/******/ }
|
158
|
+
/******/
|
159
|
+
/************************************************************************/
|
160
|
+
/******/ /* webpack/runtime/compat get default export */
|
161
|
+
/******/ (() => {
|
162
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
163
|
+
/******/ __webpack_require__.n = (module) => {
|
164
|
+
/******/ var getter = module && module.__esModule ?
|
165
|
+
/******/ () => (module['default']) :
|
166
|
+
/******/ () => (module);
|
167
|
+
/******/ __webpack_require__.d(getter, { a: getter });
|
168
|
+
/******/ return getter;
|
169
|
+
/******/ };
|
170
|
+
/******/ })();
|
171
|
+
/******/
|
172
|
+
/******/ /* webpack/runtime/define property getters */
|
173
|
+
/******/ (() => {
|
174
|
+
/******/ // define getter functions for harmony exports
|
175
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
176
|
+
/******/ for(var key in definition) {
|
177
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
178
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
179
|
+
/******/ }
|
180
|
+
/******/ }
|
181
|
+
/******/ };
|
182
|
+
/******/ })();
|
183
|
+
/******/
|
184
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
185
|
+
/******/ (() => {
|
186
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
187
|
+
/******/ })();
|
188
|
+
/******/
|
189
|
+
/******/ /* webpack/runtime/make namespace object */
|
190
|
+
/******/ (() => {
|
191
|
+
/******/ // define __esModule on exports
|
192
|
+
/******/ __webpack_require__.r = (exports) => {
|
193
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
194
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
195
|
+
/******/ }
|
196
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
197
|
+
/******/ };
|
198
|
+
/******/ })();
|
199
|
+
/******/
|
200
|
+
/******/ /* webpack/runtime/nonce */
|
201
|
+
/******/ (() => {
|
202
|
+
/******/ __webpack_require__.nc = undefined;
|
203
|
+
/******/ })();
|
204
|
+
/******/
|
205
|
+
/************************************************************************/
|
206
|
+
/******/
|
207
|
+
/******/ // startup
|
208
|
+
/******/ // Load entry module and return exports
|
209
|
+
/******/ // This entry module can't be inlined because the eval devtool is used.
|
210
|
+
/******/ __webpack_require__("./src/css/style.css");
|
211
|
+
/******/ var __webpack_exports__ = __webpack_require__("./src/js/formFunctions.js");
|
212
|
+
/******/
|
213
|
+
/******/ return __webpack_exports__;
|
214
|
+
/******/ })()
|
215
|
+
;
|
216
|
+
});
|