1console.log('contact loaded') 2 3document.querySelector('#submit-contact').addEventListener('click', submitContact) 4 5function submitContact() { 6 7 removeErrorClass("contact-form") 8 9 let name = document.querySelector('#name') 10 let phone = document.querySelector('#phone') 11 let email = document.querySelector('#email') 12 let note = document.querySelector('#note') 13 14 let errors = 0 15 16 if ( name.value.trim() == "" ) { 17 name.classList.add("error"); 18 errors++; 19 }; 20 // if ( phone.value.trim() == "" ) { 21 // phone.classList.add("error"); 22 // errors++; 23 // }; 24 if ( email.value.trim() == "" ) { 25 email.classList.add("error"); 26 errors++; 27 }; 28 if ( note.value.trim() == "" ) { 29 note.classList.add("error"); 30 errors++; 31 }; 32 33 if (errors > 0) { 34 return 35 } 36 37 let data = { 38 "name": name.value.trim(), 39 "phone": phone.value.trim(), 40 "email": email.value.trim(), 41 "note": note.value.trim() 42 } 43 44 data = JSON.stringify(data); 45 console.log(data); 46 47 document.querySelector('#contact-form').style.display = "none" 48 document.querySelector('#contact').style.display = "none" 49 document.querySelector('#contact-receipt').style.display = "block" 50 51 $.ajax({ 52 url: 'assets/scripts/ajax/send_contact_form.php', 53 type: "POST", 54 data:{"data":data}, 55 }).done(function(data) { 56 57 response = JSON.parse(data); 58 59 if (response.success == "1") 60 { 61 console.log(response.message); 62 } 63 else 64 { 65 console.log(response.message); 66 } 67 68 }); 69 70} 71 72 73function removeErrorClass(id) { 74 // Select the element with id 'contact-form' 75 const contactForm = document.getElementById(id); 76 77 if (contactForm) { 78 // Get all input elements inside the 'contact-form' element 79 const inputElements = contactForm.querySelectorAll("input, textarea"); 80 81 // Loop through each input element and remove the 'error' class 82 inputElements.forEach(input => { 83 input.classList.remove("error"); 84 }); 85 } 86}
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.