I am using a ternary operator to check whether user input is a number or not. However, when I press the check button, no matter if I input a number or a letter, an alert display "please enter a number is displayed". Here is my code.
<label style = "font-size:40px">Please Enter A Number Here: </label><input type = "text" id = "num" style = "font-size:40px">
<button type = "button" onclick = "check()">Check</button>
<script>
function check() {
var input = document.getElementById("num");
var check = /^[0-9]*$/;
(!check.test(input)) ? window.alert("You have only entered numeric characters! Please proceed to press one of the other buttons.") : window.alert("Please enter only numbers!")
}
</script>