'Alert message does not appear when input is above maximum
I have a program where an alert message appears when a number input is above maximum / below minimum. However, even if I stated for the program to do that (using if statement), it still does not function.
Did I miss an important part in the program? Thanks
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<style>
p{
color: #27186b;
}
</style>
<script>
function addNumbers() {
const number = Number(document.getElementById("number").value);
const multiplier = Number(document.getElementById("multiplier").value);
var result = "";
if (multiplier > 12) {
alert("Multiplier above maximum of 12");
return;
}
else
{
continue;
}
if (number < 2) {
alert("Number below minimum of 2");
return;
}
else
{
continue;
}
result = number * multiplier;
</script>
</head>
<body>
</br>
Enter the number : <input id="k" type="number" min="3" />
Enter the multiplier : <input id="l" type="number" max="11" />
<br />
<br />
<button onclick="addNumbers()">Print result</button>
<div id="result"></div>
</body>
</html>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
