1<script> 2jQuery(document).ready(function ($) { 3 $('.wpcf7-submit').on('click', function (e) { 4 // Get the parent form of the clicked submit button 5 alert(2222222222222); 6 var form = $(this).closest('.wpcf7-form'); 7 var contactNumberField = form.find('.contact-number'); 8 var contactNumber = contactNumberField.val().trim(); 9 var errorMessage = form.find('.contact-number-error'); 10 11 // Clear previous error message and error class 12 errorMessage.text('').removeClass('wpcf7-not-valid-tip'); 13 14 // Validate the field is not blank 15 if (contactNumber === '') { 16 e.preventDefault(); // Prevent default submit action 17 errorMessage.text('The field is required.').addClass('wpcf7-not-valid-tip'); 18 return false; 19 } 20 21 // Remove non-numeric characters 22 var digits = contactNumber.replace(/\D/g, ''); 23 24 // If the number includes a country code (+1), remove it 25 if (digits.length === 11 && digits.charAt(0) === '1') { 26 digits = digits.substring(1); 27 } 28 29 // Validate that there are exactly 10 digits 30 if (digits.length !== 10) { 31 e.preventDefault(); // Prevent default submit action 32 errorMessage.text('Must be 10 digits. May include -, (, )').addClass('wpcf7-not-valid-tip'); 33 return false; 34 } 35 36 // If we get here, the input is valid and the form can be submitted. 37 }); 38}); 39 40 41</script>
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.