I have to enter two numbers and you have to tell me if they are even or odd. It is half done but I try it and I directly jump the alert of the else, regardless of whether the numbers are even or not.
<script type="text/javascript">
function comprobar() {
var num1 = document.getElementById("num1");
var num2 = document.getElementById("num2");
if (num1 % 2 == 0 && num2 % 2 == 0) {
alert('par');
} else {
alert('impar');
}
}
</script>
<input type="text" id="num1">
<input type="text" id="num2">
<input type="button" id="boton" value="comprobar" onclick="comprobar()">