concatenate in Javascript function? simple field validation funciton not working - needs to concat field name with object

Giganews Newsgroups
Subject: concatenate in Javascript function? simple field validation funciton not working - needs to concat field name with object
Posted by:  NotGiven (nona…@nonegiven.net)
Date: Tue, 22 Jul 2003

I have a field called telephone whose ONBLUR action is to call a javascript
function:
          validatePhoneNumber(telephone)

The non-working function is:

          function validatePhoneNumber(v)
          {
          var phone =document.form. + v + .value;      //HERE"S WHAT IS
NOT WORKING
          var stripped = phone.replace(/[\(\)\.\-\ ]/g, '');
          .........//code left out for clarity
          document.form. + v + .focus()
          }

I want to reuse the function so I need to make it generic. Any ideas?

Many thanks.

Replies