I created this function to find duplicate entries in a web form, what I need is to store the index numbers of each duplicated item in another array..to
function arrTieneDups( arr )
{
var xi, xj, xn;
n=arr.length;
for (xi=0; xi<n; xi++) {
for (xj=xi+1; xj<n; xj++) {
if (arr[xi]==arr[xj]) return true;
} }
return false;
}
loop through that new array and use it as well..
for (var i in arr2)
{
$( "input[name$='matricula"+i+"']" ).addClass("errorformalta");
$( "input[name$='matricula"+i+"']" ).addClass("errorinputtext");
$( "input[name$='matricula"+i+"']" ).after('<span style="display: inline; margin-left: -20px; opacity: 1;font-size:48px;color:red;font-weight:800;" class="pyr_error_form">!</span>');
}
I am now doing as well..through the Orcuro code. But the result is not as expected. I need "var it" to be the index number of repeated items. e.g: 2,4,6 What I want is, indicate to the user the fields where they have introduced repeated data.
for (var it in arrTieneDups(matriculas) )
{
$( "input[name$='matricula"+it+"']" ).addClass("errorformalta");
$( "input[name$='matricula"+it+"']" ).addClass("errorinputtext");
$( "input[name$='matricula"+it+"']" ).after('<span style="display: inline; margin-left: -20px; opacity: 1;font-size:48px;color:red;font-weight:800;" class="pyr_error_form">!</span>');
error_validation=1;
error_top=1;
error_mat_formato="</br>! Matrícula(s) inválida(s)";
error_look="</br>Revise también los siguientes errores:";
all_ok=1;
}