I have a input box and submit button as html, I would like to enter any number in the input box and then the alert message will display if it's even or odd. If it's even than one of the paragraph text color will change to red else blue. Here's my code:
<!doctype html>
<html lang="en">
<head>
<script src="jsfile.js"></script>
</head>
<body>
<input type="text" id="inputBox"/>
<button type="button" onclick="AlertBox()">Submit</button>
<p id="p12">My first paragraph</p>
</body>
</html>
External js file:
function AlertBox()
{
var number=document.getElementById("inputBox").value;
if (number / 2 == 0)
{
alert(number + " is even and ok to go.");
document.getElementById("p12").style.color = "red";
} else
{
alert(number + " is not even and not ok to go.");
document.getElementById("p12").style.color = "blue";
}
}