Description
I am having trouble with the code below because I am trying to call the text field input type so that whenever someone enters a number above 10 it responds with the alert shown below, but I am having a problem because whenever I input a number greater than 10 in the text field it still replies with "the number is less than 10"??? What am I doing wrong? FYI I am a beginner javascript learner
<script>
//Variables
var txtInput = document.getElementById('txtInput');
//Functions
function submitNum()
{
if (txtInput <= 10)
{
alert("The number is less than 10");
}
else
{
alert("The number is greater than 10");
}
}
</script>
</head>
<body>
<input type="text" placeholder="Type any number" id="txtInput" /><input type="button" onclick="submitNum()" value="Submit" />
</body>
</html>
Explanation & Answer
At least one public class is required in main file
Review
Review
24/7 Homework Help
Stuck on a homework question? Our verified tutors can answer all questions, from basic math to advanced rocket science!