I\'m using forms in HTML and javascript. I would like an alert to pop up only if the user inputs a LETTER and clicks submit
.
So I have
A better(error-free) code would be like:
function isReallyNumber(data) {
return typeof data === 'number' && !isNaN(data);
}
This will handle empty strings as well. Another reason, isNaN("12")
equals to false
but "12"
is a string and not a number, so it should result to true
. Lastly, a bonus link which might interest you.