If you already have the textboxes in an array, loop through the array and look for duplicate values. This is not the most efficient way (it's O(n2) to compute) to solve the problem (a dictionary would be better), but for a small number of text boxes it is the simplest.
function TestForDuplicates( var Textboxes )
{
for( tb in Textboxes )
{
for( tb2 in Textboxes )
{
if( tb != tb2 ) // ignore the same textbox...
{
if( tb.value == tb2.value )
alert( "The value " + tb.value + " appears more than once." );
}
}
}
}
If you have more than about 10 textboxes in your array, an alternative approach is to build a mapping of how many times each value appears:
function FindDuplicates( var Textboxes )
{
var valueList = new Array();
for( tb in Textboxes )
valueList.push( tb.value );
valueList.sort(); // sort values so that duplicates are adjacent
if( valueList.length > 1 )
{
for( i = 0; i < valueList.length-1; i++ )
if( valueList[i] == valueList[i+1] )
alert( "The value " + valueList[i] + " appears more than once." );
}
}