When performing laboratory work there was such a problem. The first field sets the lower limit of the range of numbers, and the second - the upper one. When you enter a number in the third field, the if / else should work.
The else statement does not work in this code, so even if the range is exceeded, a message about successful typing is displayed.
What could be wrong? I don’t see the problem.
var input = document.body.children[2]; var minrange = document.getElementById('minrange').value; var maxrange = document.getElementById('maxrange').value; var integerEEE = document.getElementById('integer').value; input.oninput = function() { if (integerEEE >= minrange && integerEEE <= maxrange) { alert("Введённое число входит в заданный диапазон. Валидация пройдена. Пожалуйста перезагрузите страницу и попробуйте снова."); } else { alert("Введённое число не входит в заданный диапазон. Пожалуйста перезагрузите страницу и попробуйте снова."); }; }; </script>