function myFunction(){
var hours=prompt("Enter the numbers of hours:","Enter here");
if (hours<0)
{
alert("Inputs are negative. Click button to try again.");
return;
}
if (typeof(hours)!='number')
{
alert("Input not a number. Click ...");
return;
}
... more code }
I'm new to JavaScript and trying to test around with windows prompt. How can I control the input so that when the user inputs a negative number or a letter, it gives a warning alert and does not continue the function. The negative seems to work but the inputs as letters gives me errors. If I try to input a, it gives the error but at the same time, when I put in say 10, it also gives me the same error. I'm writing it specifically with windows prompt. Thanks in advance!