Forum Moderators: open
if ( document.feedbackform.name.value == "" )
{
alert ( "Sorry, you left name field empty. Please Enter your First and Last Name." );
document.feedbackform.name.focus();return false;
}
..but it's no so good anyway. It will accept "I am 1337", which isn't fully alpha.
Rambo's use of a regular expression is a little better suited.
It uses a regular expression literal (the forward slashes denote an RE).
\d means 'a digit'.
The ~ symbol is Rambo's way of saying 'and all that'.
It tests for the presence of digits, and rejects any strings that contain at least one digit. Hmm. This still allows characters such as @, &, #
How about:
if(/^[a-z]+$/i.test(document.feedbackform.name.value))
This also rejects no input, but comes with the same caveats as the last time I suggested it to you:
[webmasterworld.com...]