matching two fields in a form from two functions in javascript
<p>I have two fields that I'd like to match. (already done the validation functions for field 1 and 2)</p>

<p>field01 has a client number Txxxxx xxxxx (can be T G or M)</p>

<p>field02 has the area code 416 / 905 / 647</p>

<p>I'd like to match T with 416, G with 905, and M with 647.
and show a relationship error if the rules were broken.</p>

<p>I made a separate function trying to compare the two.</p>

<pre><code>     function validatecompare(errMessages)
   {

       var clientID = document.pizza.field02;
       var telenum = document.pizza.field03;

       var client = clientID.value;
       var phone  = telenum.value;
       var firstL = "";
       var areaC  = "";


firstL=client.substr(0,1);
areaC =phone.substr(0,3);


     if ((firstL) !=areaC)
       {
          errMessages += "&lt;li&gt;Client Number and Telephone No. are not consistent with our set up rules.&lt;/li&gt;\n";
       }


     return errMessages;

 }
</code></pre>

<p>I know that's wrong, I just have no idea how to compare two fields from two separate functions. The error message will pop up regardless of what I do. Even if I violate the rules for field 1 and 2 the error message will pop up with those when it shouldn't.</p>

<p>If there is somewhere I can read up on how to do this would be excellent for future reference.</p>

<p>any help would be greatly appreciated, thanks.</p>
