我正在尝试检查一个字符串是否全部a-zA-Z0-9
,但这不起作用。知道为什么吗?
var pattern=/^[a-zA-Z0-9]*$/;
var myString='125 jXw'; // this shouldn't be accepted
var matches=pattern.exec(myString);
var matchStatus=1; // say matchStatus is true
if(typeof matches === 'undefined'){
alert('within here');
matchStatus=0; // matchStatus is false
};
if(matchStatus===1){
alert("there was a match");
}