PageSourceSearch

https://neeharaa.com/assets/vendor/php-email-form/validate.js

js neeharaa.com collected 2026-09-30 04:24:53 UTC 2,734 bytes, 85 lines download raw bytes

1/**
2* PHP Email Form Validation - v3.6
3* URL: https://bootstrapmade.com/php-email-form/
4* Author: BootstrapMade.com
5*/
6(function () {
7  "use strict";
8
9  let forms = document.querySelectorAll('.php-email-form');
10
11  forms.forEach( function(e) {
12    e.addEventListener('submit', function(event) {
13      event.preventDefault();
14
15      let thisForm = this;
16
17      let action = thisForm.getAttribute('action');
18      let recaptcha = thisForm.getAttribute('data-recaptcha-site-key');
19      
20      if( ! action ) {
21        displayError(thisForm, 'The form action property is not set!');
22        return;
23      }
24      thisForm.querySelector('.loading').classList.add('d-block');
25      thisForm.querySelector('.error-message').classList.remove('d-block');
26      thisForm.querySelector('.sent-message').classList.remove('d-block');
27
28      let formData = new FormData( thisForm );
29
30      if ( recaptcha ) {
31        if(typeof grecaptcha !== "undefined" ) {
32          grecaptcha.ready(function() {
33            try {
34              grecaptcha.execute(recaptcha, {action: 'php_email_form_submit'})
35              .then(token => {
36                formData.set('recaptcha-response', token);
37                php_email_form_submit(thisForm, action, formData);
38              })
39            } catch(error) {
40              displayError(thisForm, error);
41            }
42          });
43        } else {
44          displayError(thisForm, 'The reCaptcha javascript API url is not loaded!')
45        }
46      } else {
47        php_email_form_submit(thisForm, action, formData);
48      }
49    });
50  });
51
52  function php_email_form_submit(thisForm, action, formData) {
53    fetch(action, {
54      method: 'POST',
55      body: formData,
56      headers: {'X-Requested-With': 'XMLHttpRequest'}
57    })
58    .then(response => {
59      if( response.ok ) {
60        return response.text();
61      } else {
62        throw new Error(`${response.status} ${response.statusText} ${response.url}`); 
63      }
64    })
65    .then(data => {
66      thisForm.querySelector('.loading').classList.remove('d-block');
67      if (data.trim() == 'OK') {
68        thisForm.querySelector('.sent-message').classList.add('d-block');
69        thisForm.reset(); 
70      } else {
71        throw new Error(data ? data : 'Form submission failed and no error message returned from: ' + action); 
72      }
73    })
74    .catch((error) => {
75      displayError(thisForm, error);
76    });
77  }
78
79  function displayError(thisForm, error) {
80    thisForm.querySelector('.loading').classList.remove('d-block');
81    thisForm.querySelector('.error-message').innerHTML = error;
82    thisForm.querySelector('.error-message').classList.add('d-block');
83  }
84
85})();

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.