View Single Post
Old 05-01-2011, 08:41 PM   PM User | #3
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,210
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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???
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote