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!
Similar Content
Related Tags
Harry Potter and the Sorcerers Stone
by J. K. Rowling
Fools Crow
by James Welch
The Outsiders
by S.E. Hinton
The Power of Habit - Why We Do What We Do in Life and Business
by Charles Duhigg
The Prince
by Niccolò Machiavelli
The Silent Patient
by Alex Michaelides
Of Mice and Men
by John Steinbeck
The Trial
by Franz Kafka
The Point of it All - A Lifetime of Great Loves and Endeavors
by Charles Krauthammer