Validating array of inputs using javascript
<p>I  hav  a rather large form it has 8 fields for entering books .
Now for user to add more books there is a button add more books ,on click of which a javascript function is called and  7 out of 8 fields are duplicated. </p>

<p>User can add maximum 6 books , and all the input fields created dynamically have their names as arrays . I am able to post them and store in a table , Now i want to validate them using javascript.</p>

<p>I have been tryng to do this since a week and am a new to Javascript . Please help me.</p>

<p>MY JAVASCRIPT CODE </p>

<pre><code>function addInput(divName){
 var bname1 = new Array();
 var abname1 = new Array();
 var cost1 = new Array();
 var num1 = new Array();

 if (counter == limit) 
 {
      alert("You have reached the limit of adding " + counter + " inputs");
 }
 else 
 {  
     var newdiv = document.createElement('div');
      newdiv.innerHTML ="&lt;table&gt;"+ "&lt;tr align='right'&gt;" + "&lt;td&gt;"+ " Name of book" +  (counter + 1) + "  " +" : &lt;input type='text' name='bname1[]' &gt; "+"&lt;/td&gt;" + "&lt;/tr&gt;"+"&lt;tr align='right'&gt;"+ "&lt;td&gt;"+" Name of Authour"+(counter + 1)+" "+": &lt;input type='text' name='aname1[]'&gt;"+"&lt;/td&gt;"+"&lt;/tr&gt;"+"&lt;tr align='right'&gt;"+"&lt;td&gt;"+"Publisher"+(counter+1)+" "+": &lt;input tyme='text' name='pub1[]'&gt;"+"&lt;/td&gt;"+"&lt;/tr&gt;"+ "&lt;tr align='right'&gt;" +"&lt;td&gt;"+ "ISDN Number " + (counter + 1) +" "+ ": &lt;input type='text' name='isdn1[]'&gt; "+"&lt;/td&gt;" + "&lt;/tr&gt;"+"&lt;tr align='right'&gt;" +"&lt;td&gt;"+ " Edition " + (counter + 1) + " "+": &lt;input type='text' name='edi1[]'&gt; "+"&lt;/td&gt;" + "&lt;/tr&gt;"+"&lt;tr align='right'&gt;" + "&lt;td&gt;"+ "Price"+(counter + 1) +" "+ " :&lt;input type='number' name='cost1[]'&gt;"+"&lt;/td&gt;"+"&lt;/tr&gt;"+"&lt;tr align='right'&gt;" + "&lt;td&gt;"+ "Number of copies"+(counter + 1) +" "+ ": &lt;input type='number' name ='num1[]'&gt; "+"&lt;/td&gt;" + "&lt;/tr&gt;"+ "&lt;/table&gt;";

    //  alert("counter +1 is "+counter+1);

      document.getElementById(divName).appendChild(newdiv);
     counter=counter+1;



 }
}
</code></pre>

<p>there is divsion in the html form to which all this is added.
Please help !
thanx in advance ..</p>
