<form name="contact" onsubmit="return verify(this)" action="formmail.php" method="post">
<script>
function isblank(s) { for(var i = 0; i < s.length; i++) { var c = s.charAt(i); if ((c != ' ') && (c != '\n') && (c != '\t')) return false; } return true; }
function verify(f)
{
var msg;
var errors = "";
var valemail = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
var valphone = /\d{3}-\d{3}-\d{4}/;
if (isblank(document.contact.email.value) && isblank(document.contact.phone.value))
errors = "You must enter either your email address or your phone number.\n";
if ((!isblank(document.contact.email.value)) && (!document.contact.email.value.match(valemail)))
errors = "You must enter a valid email address (user@domain.name).\n";
if ((!isblank(document.contact.phone.value)) && (!document.contact.phone.value.match(valphone)))
errors = "You must enter a valid phone number (123-456-7890).\n";
if (isblank(document.contact.comments.value))
errors += "You did not enter any comments or requests.\n";
if (!errors) {
if (isblank(document.contact.email.value)) document.contact.email.value = "webmaster@pcvsoftware.net";
return true;
}
msg = "______________________________________________________________\n\n";
msg += "The form was not submitted because of the following error(s).\n";
msg += "Please correct your entries and re-submit.\n";
msg += "______________________________________________________________\n\n";
msg += errors;
alert(msg);
return false;
}</scirpt>
0 comments:
Post a Comment