(function($){ $(document).ready(function() { $("form.validate #email").focus(function() { if ($(this).val() == "Your email address") {$(this).val('');} if ($(this).val() == "Invalid email. Try again.") { $(this).val(''); $(this).attr('style',''); } }); $("form.validate #email").blur(function() { if ($(this).val() == '') { $(this).val('Your email address'); } }); $("form.validate #email").blur(function() { if ($("form.validate #email").val() == 'Invalid email. Try again.') { $("form.validate #email").val('Your email address'); $("form.validate #email").attr('style',''); } }); }); })(jQuery); function valid_email(the_form) { var el = the_form.email; var val = el.value; var isValid = true; var Regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if (!Regex.test(val)) { isValid = false; } if( !isValid ) { el.value = 'Invalid email. Try again.'; el.style.color = 'red'; } return isValid; } function check_form(the_form) { var a = valid_email(the_form); return (a); }