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
I know this post is old but it was the first one that popped up when I did a search. I tried @Kim Kling RegExp but it failed miserably. Also prior to finding this forum I had tried almost all the other variations listed here. In the end, none of them worked except this one I created; it works fine, plus it is es6:
const regex = new RegExp(/[^0-9]/, 'g');
const x = document.forms["myForm"]["age"].value;
if (x.match(regex)) {
alert("Must be a valid number");
return;
}