Reputation: 271634
In JavaScript, how can I find out whether a string has a-z in it? Is there a simple function?
Upvotes: 0
Views: 840
Reputation: 598
Try this one:
function checkkey(v) {
if (/\W/.test(v.value)) {
alert("Please enter alphanumerics only");
return false;
}
return true;
}
W is a shortcut to [^a-zA-Z0-9_]
.
Change W to: [^a-zA-Z_]
Upvotes: 1
Reputation: 498924
You can use a regular expression.
Not sure what you mean by a-z
- that exact string, or simply lower case letters? Or do you mean something else?
Upvotes: 0