Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <body>
- <p>Guess my age:</p>
- <input id="age" type="number">
- <button type="button" onclick="myFunction()">Enter</button>
- <p id="abc"></p>
- <script>
- function myFunction() {
- var x, text;
- x = document.getElementById("age").value;
- if (isNaN(x) || x < 19) {
- text = "Too young!";
- }
- else if (isNaN(x) || x > 19) {
- text = "Too old!";
- }
- else {
- text = "Correct!";
- }
- document.getElementById("abc").innerHTML = text;
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement