PageSourceSearch

https://www.podchlumi.cz/bundles/kontaktniform/js/check.js?v=v6.5.0

js podchlumi.cz collected 2026-10-02 18:47:05 UTC 4,054 bytes, 117 lines download raw bytes

1const ContactFormValidator = {
2    sendCopyCheckbox: null,
3    mailInput: null,
4
5    validateEmail: function (email) {
6        const re =
7            /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
8        return re.test(email);
9    },
10
11    validate: function (withAlerts) {
12        if (!withAlerts) {
13            this.clearAlerts();
14
15            const nameInput = document.getElementById('contact_form_name');
16            const subjectInput = document.getElementById('contact_form_subject');
17            const messageArea = document.getElementById('contact_form_content');
18            const captchaInput = document.getElementById('captcha_input');
19
20            if ('' === nameInput.value.trim()) {
21                nameInput.focus();
22                this.wrapperAlert(nameInput);
23
24                return false;
25            }
26
27            if ('' === subjectInput.value.trim()) {
28                subjectInput.focus();
29                this.wrapperAlert(subjectInput);
30
31                return false;
32            }
33
34            if ('' === messageArea.value.trim()) {
35                messageArea.focus();
36                this.wrapperAlert(messageArea);
37
38                return false;
39            }
40
41            if ('' === captchaInput.value.trim()) {
42                captchaInput.focus();
43                this.wrapperAlert(captchaInput);
44
45                return false;
46            }
47        }
48
49        const streetInput = document.getElementById('contact_form_street');
50        const cityInput = document.getElementById('contact_form_city');
51        const codeInput = document.getElementById('contact_form_postcode');
52        const phoneInput = document.getElementById('contact_form_phone');
53
54        if (
55            '' === streetInput.value.trim() &&
56            '' === phoneInput.value.trim() &&
57            '' === ContactFormValidator.mailInput.value
58        ) {
59            withAlerts ? alert(gcm.Lang.L_PODAT_EMPTYKON) : this.wrapperAlert(streetInput);
60            streetInput.focus();
61
62            return false;
63        }
64
65        if ('' !== streetInput.value.trim() && '' === cityInput.value.trim()) {
66            withAlerts ? alert(gcm.Lang.L_PODAT_EMPTYMES) : this.wrapperAlert(cityInput);
67            cityInput.focus();
68
69            return false;
70        }
71
72        if ('' !== streetInput.value.trim() && '' === codeInput.value.trim()) {
73            withAlerts ? alert(gcm.Lang.L_PODAT_EMPTYPSC) : this.wrapperAlert(codeInput);
74            codeInput.focus();
75
76            return false;
77        }
78
79        return true;
80    },
81
82    wrapperAlert: function (element) {
83        element.classList.add('podatelna__input--invalid');
84        const parent = element.parentElement;
85        const alert = document.createElement('div');
86        alert.className = 'podatelna__alert';
87        const alertInner = document.createElement('span');
88        alertInner.innerText = window.gcm.Lang['L_SPATNE_POLICKA2'];
89        alert.appendChild(alertInner);
90        parent.appendChild(alert);
91    },
92
93    init: function () {
94        ContactFormValidator.sendCopyCheckbox = document.getElementById('contact_form_send_copy');
95        ContactFormValidator.mailInput = document.getElementById('contact_form_email');
96
97        ContactFormValidator.mailInput.addEventListener('input', function (event) {
98            ContactFormValidator.sendCopyCheckbox.disabled = !ContactFormValidator.validateEmail(event.target.value);
99        });
100    },
101
102    clearAlerts: function () {
103        const wrappers = document.getElementsByClassName('podatelna__input--invalid');
104
105        Array.from(wrappers).forEach((element) => {
106            element.classList.remove('podatelna__input--invalid');
107        });
108
109        const alerts = document.getElementsByClassName('podatelna__alert');
110
111        Array.from(alerts).forEach((element) => {
112            element.parentElement.removeChild(element);
113        });
114    },
115};
116
117document.addEventListener('DOMContentLoaded', ContactFormValidator.init);

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.