I bet if you post your 3 form fields, and your function, I can shorten (or improve) it considerably, at least if you're only dealing with US and Canadian phone numbers...
Just a tip to shorten your script (wow, that sounds like Dr. Suess!):
If you're using something like document.mailform.
over and over again, set it to a variable, such as:
var f = document.mailform;
From that point on, you can say stuff like:
if (f.night_phone_a.value == "" | f.night_phone_b.value == "" | f.night_phone_c.value == "") {
instead of the really lengthy code you have.
Alternatively (and even better), you can just use (f) in the function parameter, and pass (this)
from the form tag using onsubmit. What that does, is passes the form object to the function parameter "f" right when you're calling the function - that way the function always knows that "f" is the form that called the function... get it? If not, here's an example that might clarify what I mean, since sometimes I'm better at explaining with code:
Code:
<html>
<head>
<title>Example</title>
<script type="text/javascript">
<!--
function alertFormName(f) {
alert(f.name + f.punctuation.value);
return false;
}
// -->
</script>
</head>
<body>
<form name="Yay" action="javascript://" onsubmit="alertFormName(this)">
<input type="hidden" name="punctuation" value="!!!" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
Also, I'd rather allow people to type a phone number all in one field, and then validate the phone number against a regular expression, rather than having to deal with three separate fields for each phone number.