复制代码 代码如下:
function checkFormat(str) { if (escape(str).indexOf("%u")!=-1) alert("不能含有汉字"); else if(str.match(/\D/)!=null) { alert('不能含有字母'); } }
查看更多关于用正则表达式判断字符串是汉字还是拼音的js函数的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did9246
复制代码 代码如下:
function checkFormat(str) { if (escape(str).indexOf("%u")!=-1) alert("不能含有汉字"); else if(str.match(/\D/)!=null) { alert('不能含有字母'); } }
查看更多关于用正则表达式判断字符串是汉字还是拼音的js函数的详细内容...