If he types 1, I have to check if there is no value 1 in the table that has already been typed, if there is a value repeated, it removes the value 1 and keeps the other one intact. So for other values.
HTML
<table>
<tr>
<td><input type="text" name="notapergunta2_1" placeholder="Alfa"/> Alfa</td>
<td><input type="text" name="notapergunta2_2" placeholder="Chub"/> Chub</td>
<td><input type="text" name="notapergunta2_3" placeholder="Met "/> Met </td>
</tr>
<tr>
<td><input type="text" name="notapergunta2_4" placeholder="A"/> A</td>
<td><input type="text" name="notapergunta2_5" placeholder="G"/> G</td>
<td><input type="text" name="notapergunta2_6" placeholder="N"/> N</td>
</tr>
<tr>
<td><input type="text" name="notapergunta2_7" placeholder="ASS"/> ASS</td>
<td><input type="text" name="notapergunta2_8" placeholder="Hdi"/> Hdi</td>
<td><input type="text" name="notapergunta2_9" placeholder="Porto"/> Porto </td>
</tr>
</table>
My javascript:
array = []
for(var i = 0; i<9;i++){
var numeroDaPergunta = i+1;
$("[name='notapergunta2_"+numeroDaPergunta+"']").on("change",function(){
var verificaValorDigitado = $(this).val();
if(verificaValorDigitado > 3 || verificaValorDigitado <= 0){
alert("Valor Digitado : "+verificaValorDigitado+"\nDigite Números de 1 a 3");
$(this).val("");
} else {
array.push($(this).val());
for(var j = 0; j<array.length; j++){
if(verificaValorDigitado == array[j]){
alert("Valor Repetido");
$(this).val("");
return false;
}
}
}
});
}
I can not find a solution, could you help me?