Several things wrong.
Just for starters, you do this:
Code:
if (testLength(wform.total)== false) isValid = false;
but that generates an error in
testLength() because there is no element with the ID "totalcontact".
Why is your code looking for "totalcontact"??
Because you do this in
testLength:
Code:
document.getElementById(field.id+"contact").style.bgcolor= ...
So when you try to do testLength() of the total field, which has an id of "total", you try to set the background color of something with the id of "totalcontact".
And ditto for every field that you invoke testLength() on.
And similar for
testPattern, where you do worse:
Code:
function testPattern(field, reg) {
var isValid = true;
wsregx = /\s/g;
var fv =field.value.replace(wsregx,"");
if (reg.test(fv) == false) {
isValid = false;
document.getElementById(input.id+"fname").style.bgcolor="yellow";
} else {
document.getElementById(input.id+"fname").style.bgcolor="white";
}
return isValid;
}
Here, you are trying to append "fname" to
input.id. But
input is not even a valid variable at this point in the code.
I'm *guessing* that you meant to use
field.id, but that makes no sense, either, as you don't have any elements with an id of "xxxfname" except "fname" itself.
Quite frankly, I don't understand what the point of appending these strings to these ids is. Are you missing a bunch of tags that should, indeed, have ids such as "totalcontact" and "fnamecontact" and so on???