开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜