I want to compare two inputs minimumN and maximumN, and display an alert if the logic is not satisfied, I have the following code:
HTML:
<table>
<tr>
<th>Minimum N</th>
<td>
<input id="minN" onkeyup="MinimumNValidate()" type="text" maxlength="50">
</td>
<th>Maximum N</th>
<td>
<input id="maxN" onkeyup="MaximumNValidate()" type="text" maxlength="50">
</td>
</tr>
</table>
Javascript:
function MinimumNValidate() {
var min = document.getElementById("minN").value;
var max = document.getElementById("maxN").value;
if (min > max) {
alert("Minimum value must be lesser than maximum value.");
}
}
function MaximumNValidate() {
var min = document.getElementById("minN").value;
var max = document.getElementById("maxN").value;
if (max < min) {
alert("Maximum value must be greater than minimum value.");
}
}
but this is not working, and the alert is being displayed even when the minN is less than maxN, can you point out the mistake in my code ?
var min = parseInt(document.getElementById("minN").value);var max = parseInt(document.getElementById("maxN").value);