Jquery check for alphanumeric charactres
In the below code Using jquery how to check for only alaphanumeric charaters.Even space and none of the special symbols should be allowed.I do want o use a external plugin
var a='a hjdshj%^& ff234 ./.';
if(var a has special ch开发者_运维问答aracters)
{
alert('has special characters');
}
EDIT
: Even single and double quotes should not be allowed
There is no need of any plugin to check this
you can make use of Regular exprssion to do it easily..
try this
var str='a hjdshj%^& ff234 ./.';
var re = new RegExp(/\$|\/|\^|-/\s,"g");
specialchars = str.match(re);
alert(specialchars.length);
精彩评论