/    Sign up×
Community /Pin to ProfileBookmark

Validation: letters only

Sorry bit of a beginner here, how do i do a simple validation so only letters (no numbers or symbols can be entered) into a “Whats your name? form” will be inputted to a form. ive done everything else but can’t get the validation right.

I only need the code form the if statement.

Also i want the name from the form to appear in another page, is this possible if so how?

Thanks

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@pyroJan 14.2004 — What if their name has a special character in it?
Copy linkTweet thisAlerts:
@SpaauthorJan 15.2004 — Ok forget about symbols, i have to have some sort of validation, so what "if" statement do i use to make sure no numbers can be used?
Copy linkTweet thisAlerts:
@fredmvJan 15.2004 — if(/d/g.test(field.value))
{
// code
}
Copy linkTweet thisAlerts:
@SpaauthorJan 15.2004 — Im not sure where the nName part goes, the "text" is the part that i wasn't sure about.

Thanks for replying.


if (nName = "text")

{ window.location.href ="interaction.htm"

}

else

{ alert("Please enter a valid name");

}
Copy linkTweet thisAlerts:
@fredmvJan 15.2004 — I believe this is what you want:if (!/d/g.test(nName)) location = 'interaction.htm';

else
{
alert('Name cannot contain numbers.');
return false;
}
Copy linkTweet thisAlerts:
@SpaauthorJan 15.2004 — Thanks thats great.
×

Success!

Help @Spa spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...