I'm doing a validation in which I can register numbers from 1 to 100, the more an error message comes out and the texbox is cleaned, it works perfect, when the user leaves that texbox he jumps the second message saying that introduces the number since it can not be empty, I show you the code.
<td><input type="number" style="width:45px;" id = "txtNotaDecidir<%:contDecidir %>" min="0" max="100" onblur = "Validar(event, this.id)" onkeyup = "ValidarNumero(event, this.id)" ng-model="model.selected.<%: eval.ColNota %>" /></td>
<script type="text/javascript">
document.addEventListener('keyup', Validar, true);
function ValidarNumero(nota) {
var idTexto = document.activeElement.id;
var num = document.getElementById(idTexto).value;
if (parseFloat(num) < 0 || parseFloat(num) > 100) {
alert("El numero no puede ser mayor a 100");
document.getElementById(idTexto).focus;
return document.getElementById(idTexto).value = "";
} else
return nota.value;
}
document.addEventListener('onblur', Validar, false);
function Validar(nota,id) {
var num = document.getElementById(id).value;
if (num == "") {
alert("Introduzca nota");
document.getElementById(id).focus;
}
else
return nota.value;
}
</script>
My question is because when I enter a number greater than 100 it shows me the two error windows all the time, it does not let me do anything through the windows, which may be wrong in the code, please help ...