用正则表达式判断字符串是汉字还是拼音的js函数代码
作者:用户投稿 浏览: 发布日期:2026-01-16
[导读]:用正则表达式判断字符串是汉字还是拼音的js函数代码,需要的朋友可以参考下。
复制代码 代码如下:
function checkFormat(str)
{
if (escape(str).indexOf("%u")!=-1)
alert("不能含有汉字");
else if(str.match(/\D/)!=null)
{
alert('不能含有字母');
}
}
免责声明:转载请注明出处:http://m.lexweb.cn/news/70773.html