$(document).ready(function(){ // Encrypt e-mail address to hide from Spambots spambotBuster(); $("form").submit(function () { var valid = true; var confirm = document.getElementById('emailConfirm').value; var email = document.getElementById('email').value; if(confirm != email) { valid = false; } // if the form didn't validate then focus the input on the first error if (!valid) { $("#confirmLabel").addClass("error"); //add in error description var li = $('
  • '); var span = $('').addClass('error').text('The email confirmation field didn\'t match the email you entered.'); li.append(span); $("#contactForm").find('li:eq(3)').after(li); $("#email").focus(); } //check phone number var phone = document.getElementById('telephone').value; var phoneerror = checkEmail(phone); if (phoneerror != null) { var li = $('
  • '); var span = $('').addClass('error').text(phoneerror); li.append(span); $("#contactForm").find('li:eq(2)').after(li); $("#telephone").focus(); valid = false; } return valid; }); }); function checkEmail(strng) { var error = null; var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters if (isNaN(parseInt(stripped))) { error = "The phone number contains illegal characters."; } if (!(stripped.length == 10)) { error = "The phone number is the wrong length. Make sure you included an area code."; } return error; } function spambotBuster() { var linktext = "info@neopathhealth.com"; var emaila = "info"; var emailb = "neopathhealth"; var emailc = "com"; //create the actual link theLink = "mailto:" + emaila + "@" + emailb + "." + emailc; //build node for email link var emailLink = $(''); emailLink.text(linktext); emailLink.attr({'href': theLink}); //replace it! $('span.emaillink').text(''); $('span.emaillink').append(emailLink); }