PageSourceSearch

https://www.hazelbrow.co.uk/wp-content/themes/hazel-brow/assets/js/booking.form.js

js hazelbrow.co.uk collected 2026-09-27 07:30:50 UTC 3,255 bytes, 90 lines download raw bytes

1/*
2--------------------------------
3Ajax Contact Form
4--------------------------------
5+ https://github.com/pinceladasdaweb/Ajax-Contact-Form
6+ A Simple Ajax Contact Form developed in PHP with HTML5 Form validation.
7+ Has a fallback in jQuery for browsers that do not support HTML5 form validation.
8+ version 1.0.1
9+ Copyright 2014 Pedro Rogerio
10+ Licensed under the MIT license
11+ https://github.com/pinceladasdaweb/Ajax-Contact-Form
12*/
13
14(function ($, window, document, undefined) {
15    'use strict';
16
17    var $form = $('#booking-form');
18
19    $form.submit(function (e) {
20        // remove the error class
21        $('#booking-form input, #booking-form select').removeAttr('style');
22
23        // get the form data
24        var formData = {
25            'room' : $('input[name="form-room"]').val(),
26            'checkin' : $('input[name="form-checkin"]').val(),
27            'checkout' : $('input[name="form-checkout"]').val(),
28            'adults' : $('select[name="form-adults"]').val(),
29            'childrens' : $('select[name="form-childrens"]').val(),
30            'name' : $('input[name="form-name"]').val(),
31            'surname' : $('input[name="form-surname"]').val(),
32            'email' : $('input[name="form-email"]').val(),
33            'phone' : $('input[name="form-phone"]').val(),
34            'address1' : $('input[name="form-address1"]').val(),
35            'address2' : $('input[name="form-address2"]').val(),
36            'city' : $('input[name="form-city"]').val(),
37            'country' : $('input[name="form-country"]').val(),
38            'requirements' : $('textarea[name="form-requirements"]').val()
39        };
40
41        // process the form
42        $.ajax({
43            type : 'POST',
44            url  : 'booking.php',
45            data : formData,
46            dataType : 'json',
47            encode : true
48        }).done(function (data) {
49            // handle errors
50            if (!data.success) {
51                if (data.errors.checkin) {
52                    $('#form-checkin').css('border-color','#ff0000');
53                }
54                
55                if (data.errors.checkout) {
56                    $('#form-checkout').css('border-color','#ff0000');
57                }
58                
59                if (data.errors.adults) {
60                    $('#form-adults').css('border-color','#ff0000');
61                }
62                
63                if (data.errors.name) {
64                    $('#form-name').css('border-color','#ff0000');
65                }
66                
67                if (data.errors.surname) {
68                    $('#form-surname').css('border-color','#ff0000');
69                }
70                
71                if (data.errors.email) {
72                    $('#form-email').css('border-color','#ff0000');
73                }
74                
75                if (data.errors.phone) {
76                    $('#form-phone').css('border-color','#ff0000');
77                }
78            } else {
79                // display success message
80                $(".booking-form").hide();
81                $(".booking-complete").show();
82            }
83        }).fail(function (data) {
84            // for debug
85            console.log(data)
86        });
87
88        e.preventDefault();
89    });
90}(jQuery, window, document));

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.