title: Javascript match with wildcard
body: <p>Hi and thanks for looking.</p>
  
  <p>I need to get all form inputs from a form using javascript, the inputs are named like so:</p>
  
  <pre><code>&lt;input name="site[1]" type="text" size="3" id="sitesinput" value="0" /&gt;
  &lt;input name="site[2]" type="text" size="3" id="sitesinput" value="0" /&gt;
  &lt;input name="site[3]" type="text" size="3" id="sitesinput" value="0" /&gt;
  &lt;input name="site[4]" type="text" size="3" id="sitesinput" value="0" /&gt;
  </code></pre>
  
  <p>......</p>
  
  <pre><code>&lt;input name="site[10]" type="text" size="3" id="sitesinput" value="0" /&gt;
  </code></pre>
  
  <p>and I have the following to pick them up and adding the values togther, but it is not working, what am I doing wrong:</p>
  
  <pre><code>function site_change() {
           var sites= document.getElementById('sitesinput').value;    
           var sum= 0;
           var inputs= document.getElementById('inputsite').getElementsByTagName('input');
           for (var i= inputs.length; i--&gt;0;) {
              if (inputs[i].getAttribute('name').match(/^site[\d+$]/))
              {
               var v= inputs[i].value.split(',').join('.').split(' ').join('');
               if (isNaN(+v))
                   alert(inputs[i].value+' is not a readable number');
               else
                   sum+= +v;
              }
           }
           var phones= document.getElementById('phonesinput').value;
           document.getElementById('siteresult').innerHTML = phones-sum;
      };
  </code></pre>
  
  <p>Is the Match function wrong?</p>
  
  <p>Thanks,
  B.</p>