1 2// JavaScript contact form Document 3$(document).ready(function() { 4 $('form#contact-form').submit(function() { 5 $('form#contact-form .error').remove(); 6 var hasError = false; 7 $('.requiredField').each(function() { 8 if(jQuery.trim($(this).val()) == '') { 9 var labelText = $(this).prev('label').text(); 10 $(this).parent().append('<span class="error">You forgot to enter your '+labelText+'</span>'); 11 $(this).addClass('inputError'); 12 hasError = true; 13 } else if($(this).hasClass('email')) { 14 var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; 15 if(!emailReg.test(jQuery.trim($(this).val()))) { 16 var labelText = $(this).prev('label').text(); 17 $(this).parent().append('<span class="error">You entered an invalid '+labelText+'</span>'); 18 $(this).addClass('inputError'); 19 hasError = true; 20 } 21 } 22 }); 23 if(!hasError) { 24 $('form#contact-form input.submit').fadeOut('normal', function() { 25 $(this).parent().append(''); 26 }); 27 28 $("#loader").show(); 29 $.ajax({
30 url: "contact.php", 31 type: "POST", 32 data: new FormData(this), 33 contentType: false, 34 cache: false, 35 processData:false, 36 success: function(data){ 37 $('form#contact-form').slideUp("fast", function() { 38 $(this).before('<div class="success">Thank you. Your Email was sent successfully.</div>'); 39 $("#loader").hide(); 40 }) 41 } 42 }); 43 44 return false; 45 } 46 47 }); 48});
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.