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 the HTML code:
<form name="myForm" action="" onsubmit="return checkInp()" method="post">
First name: <input type="text" name="age">
<input type="submit" value="Submit">
And the javascript code:
function checkInp()
{
var x=document.forms["myForm"]["age"].value;
if (x consists of any letters) // this is the code I need to change
{
alert("Must input numbers");
return false;
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…