PageSourceSearch

https://www.mairie-courgis-89.com/js/contact-form.js

js mairie-courgis-89.com collected 2026-10-02 23:02:12 UTC 3,062 bytes, 96 lines download raw bytes

1$(document).ready(function() {
2  $("#feedbackSubmit").click(function() {
3    var $btn = $(this);
4    $btn.button('loading');
5    //clear any errors
6    contactForm.clearErrors();
7
8    //do a little client-side validation -- check that each field has a value and e-mail field is in proper format
9    var hasErrors = false;
10    $('#feedbackForm input,textarea').not('.optional').each(function() {
11      if (!$(this).val()) {
12        hasErrors = true;
13        contactForm.addError($(this));
14      }
15    });
16    var $email = $('#email');
17    if (!contactForm.isValidEmail($email.val())) {
18      hasErrors = true;
19      contactForm.addError($email);
20    }
21
22    var $phone = $('#phone');
23    if (!contactForm.isValidPhone($phone.val())) {
24      hasErrors = true;
25      contactForm.addError($phone);
26    }
27
28    //if there are any errors return without sending e-mail
29    if (hasErrors) {
30      $btn.button('reset');
31      return false;
32    }
33
34    //send the feedback e-mail
35    $.ajax({
36      type: "POST",
37      url: "librairie/envoimel.php",
38      data: $("#feedbackForm").serialize(),
39      success: function(data) {
40        contactForm.addAjaxMessage(data.message, false);
41        contactForm.clearForm();
42        //get new Captcha on success
43        $('#captcha').attr('src', 'librairie/securimage/securimage_show.php?' + Math.random());
44      },
45      error: function(response) {
46        contactForm.addAjaxMessage(response.responseJSON.message, true);
47      },
48      complete: function() {
49        $btn.button('reset');
50      }
51   });
52    return false;
53  });
54  $('#feedbackForm input').change(function () {
55    var asteriskSpan = $(this).siblings('.glyphicon-asterisk');
56    if ($(this).val()) {
57      asteriskSpan.css('color', '#00FF00');
58    } else {
59      asteriskSpan.css('color', 'black');
60    }
61  });
62});
63
64//namespace as not to pollute global namespace
65var contactForm = {
66  isValidEmail: function (email) {
67    var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
68    return regex.test(email);
69  },
70  /**
71* Validates that phone number has 10 digits.
72*
73* @param {String} phone phone number to validate
74* @return {Boolean} if phone number is valid
75*/
76  isValidPhone: function (phone) {
77    phone = phone.replace(/[^0-9]/g, '');
78    return (phone.length === 10);
79  },
80  clearErrors: function () {
81    $('#emailAlert').remove();
82    $('#feedbackForm .help-block').hide();
83    $('#feedbackForm .form-group').removeClass('has-error');
84  },
85  clearForm: function () {
86    $('.glyphicon-asterisk').css('color', 'black');
87    $('#feedbackForm input,textarea').val("");
88  },
89  addError: function ($input) {
90    $input.siblings('.help-block').show();
91    $input.parent('.form-group').addClass('has-error');
92  },
93  addAjaxMessage: function(msg, isError) {
94    $("#feedbackSubmit").before('<div id="emailAlert" class="alert alert-' + (isError ? 'danger' : 'success') + '" style="margin-top: 5px;">' + $('<div/>').text(msg).html() + '</div>');
95  }
96};

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.