javascript-multiple-input-textbox-validation
<p>I have <code>n</code> number of textboxes on a form. After the user enters a value in a textbox, I need to check that it's not a duplicate of any of the other textboxes. For example:</p>

<pre><code>Textbox[0] : 1
Textbox[1] : 2 
Textbox[2] : 3
Textbox[4] : 1
</code></pre>

<p>It should alert saying that '1' has been entered twice.</p>

<p>I tried the following:</p>

<pre><code>function findDuplicates ( obj ) {
    var inputs = document.getElementsByName('analog_idorder[]');
    var answers= new Array();

    for(var ii = 0; ii &lt; inputs.length; ii++) {
        if(inputs[ii].type == 'text') {
            for(var jj = 0; jj &lt; answers.length; jj++) {
                if(answers[jj] == inputs[ii].value)
                    alert('Duplicate Id_order number');
                return false;
            }
            answers.push(inputs[ii].value);
        }
    }
    return true;
}
</code></pre>

<p>But only the first two textboxes validate.</p>

<p>Let me know how I can solve this problem.</p>
