var str = "abc"; if(/^[a-zA-Z]*$/.test(str)) { alert("“" + str + "”里全是字母!"); } else if(/^[\u4e00-\u9fa5]*$/.test(str)) { alert("“" + str + "”里全是汉字!"); }
js、javascript判断是汉字还是字母
最新推荐文章于 2023-04-25 14:39:31 发布

var str = "abc"; if(/^[a-zA-Z]*$/.test(str)) { alert("“" + str + "”里全是字母!"); } else if(/^[\u4e00-\u9fa5]*$/.test(str)) { alert("“" + str + "”里全是汉字!"); }