I have n
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:
Textbox[0] : 1
Textbox[1] : 2
Textbox[2] : 3
Textbox[4] : 1
It should alert saying that '1' has been entered twice.
I tried the following:
function findDuplicates ( obj ) {
var inputs = document.getElementsByName('analog_idorder[]');
var answers= new Array();
for(var ii = 0; ii < inputs.length; ii++) {
if(inputs[ii].type == 'text') {
for(var jj = 0; jj < answers.length; jj++) {
if(answers[jj] == inputs[ii].value)
alert('Duplicate Id_order number');
return false;
}
answers.push(inputs[ii].value);
}
}
return true;
}
But only the first two textboxes validate.
Let me know how I can solve this problem.