PageSourceSearch

https://michalkutzendorfer.cz/www/js/estimate-form.js?v=4

js michalkutzendorfer.cz collected 2026-10-08 13:19:21 UTC 4,303 bytes, 154 lines download raw bytes

1$('input[name=property_type]').change(function() {
2    $('#form-fields').slideDown(300);
3    if ($("input[name=property_type]:checked").val() == 'house') {
4        $('.flat').slideUp(300);
5        $('.house').slideDown(300);
6    } else {
7        $('.house').slideUp(300);
8        $('.flat').slideDown(300);
9    }
10    var pos = $('#form-fields').offset();
11    $("html, body").animate({ scrollTop: pos.top });
12});
13
14function submitEstimateForm() {
15    if (validateEstimateForm()) {
16        $('#frm-estimateForm-estimateForm').submit();
17    }
18}
19
20function validateEstimateForm() {
21    var isValid = true;
22    var focus = false;
23
24    if (!$("select[name=rating] option:selected").val()) {
25        $('#rating-error').show();
26        $('select[name=rating]').addClass('input-error');
27        isValid = false;
28        if (!focus) {
29            $('select[name=rating]').focus();
30            focus = true;
31        }
32    }
33
34    if (!$("select[name=ownership] option:selected").val()) {
35        $('#ownership-error').show();
36        $('select[name=ownership]').addClass('input-error');
37        isValid = false;
38        if (!focus) {
39            $('select[name=ownership]').focus();
40            focus = true;
41        }
42    }
43
44    $('#frm-estimateForm-estimateForm input:not(.optional)').each(function() {
45        if ($(this).val() === '') {
46            $(this).siblings('.field-error').show();
47            $(this).addClass('input-error');
48            isValid = false;
49            if (!focus) {
50                $(this).focus();
51                focus = true;
52            }
53        }
54    });
55
56    $('#frm-estimateForm-estimateForm input.integer').each(function() {
57        var value = $(this).val().trim();
58        if (value !== '' && !/^[0-9]+$/.test(value)) {
59            $(this).siblings('.format-error').show();
60            $(this).addClass('input-error');
61            isValid = false;
62            if (!focus) {
63                $(this).focus();
64                focus = true;
65            }
66        }
67    });
68
69    // email
70    let email = $('#frm-estimateForm-estimateForm-email');
71    if (!validateEmail(email.val()) && email.val() != '')
72    {
73        email.siblings('.format-error').show();
74        email.addClass('input-error');
75        isValid = false;
76        if (!focus) {
77            $(this).focus();
78            focus = true;
79        }
80    }
81
82    // telefon
83    let phone = $('#frm-estimateForm-estimateForm-phone');
84    if (!validatePhoneNumber(phone.val()) && phone.val() != '')
85    {
86        phone.siblings('.format-error').show();
87        phone.addClass('input-error');
88        isValid = false;
89        if (!focus) {
90            $(this).focus();
91            focus = true;
92        }
93    }
94
95    if (!$('#frm-estimateForm-estimateForm-privacy').is(':checked'))
96    {
97        $('.privacy-error').show();
98        isValid = false;
99        if (!focus) {
100            $(this).focus();
101            focus = true;
102        }
103    }
104
105    return isValid;
106}
107
108$('input[name="more"]').click(function() {
109    if ($(this).is(':checked')) {
110        $('#optional-fields').slideDown(300);
111    } else {
112        $('#optional-fields').slideUp(300);
113    }
114});
115
116$(document).ready(function () {
117    $('#frm-estimateForm-estimateForm input:not(.optional)').change(function () {
118        $(this).siblings('.field-error').hide();
119        $(this).siblings('.format-error').hide();
120        $(this).removeClass('input-error');
121    });
122
123    $('#frm-estimateForm-estimateForm-privacy').change(function () {
124        $('.privacy-error').hide();
125    });
126
127    $('select[name=rating]').change(function() {
128        $('#rating-error').hide();
129        $(this).removeClass('input-error');
130    });
131
132    $('select[name=ownership]').change(function() {
133        $('#ownership-error').hide();
134        $(this).removeClass('input-error');
135    });
136
137    $('select').change(function() {
138        if ($(this).find("option:selected").val()) {
139            $(this).addClass('valid');
140        } else {
141            $(this).removeClass('valid');
142        }
143    });
144});
145
146function validatePhoneNumber(phone) {
147    var regex = /^(\+420|\+421|0)? ?[1-9] ?[0-9] ?[0-9] ?[0-9] ?[0-9] ?[0-9] ?[0-9] ?[0-9] ?[0-9]$/;
148    return regex.test(phone);
149}
150
151function validateEmail(email) {
152    var regex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
153    return regex.test(email);
154}

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.