function validateEmail ( fieldId ) {
var field = document.getElementById( fieldId );
var address = field.value;
//based on 'valid email' by krisdb via snipplr.com
var filter=/^.+@.+\..{2,3}$/;
return (function (){
if (filter.test(address))
return true;
else {
if (address == '') {
alert('Please enter a valid email address before submitting the form.');
} else {
alert('"' + address + '" is not a valid email address. Please correct your address and try again.');
}
field.focus();
return false;
}
})();
}
window.onload = function() {
clearOnInitialFocus('email');
document.forms[0].onsubmit = function () { return validateEmail('email') };
}