难道此问题无法解决吗?????

yuyu123 2003-12-13 11:33:27
难道此问题无法解决吗?????

用户只能输入中文名字!用正则表达式怎么写???我验证\xaa-\xff这一段还不行
...全文
22 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
learnerX 2003-12-13
  • 打赏
  • 举报
回复
d
oldmht 2003-12-13
  • 打赏
  • 举报
回复
客户端验证:
<html>
<body>
<form action="test.asp" name="form1" onSubmit="return checkForm()">
<input name="test" type="text">
<input type="submit">
</form>
<script>
function checkForm(){
var checkStr=form1.test.value
if (!checkStr) return false
for (var i=0;i<checkStr.length;i++)
if (checkStr.charCodeAt(i)<256) {
alert('对不起,只能输入中文')
return false
}
}
</script>
</body>
</html>

服务器端验证:
<%
dim testStr,i
testStr=request("test")
if testStr="" then
response.write "<script>history.back();</script>"
response.end
end if
for i=1 to len(testStr)
if asc(mid(testStr,i,1))>0 then
response.write "<script>"&vbcrlf&"alert('对不起,只能输入中文');"&vbcrlf&"history.back();"&vbcrlf&"</script>"
response.end
end if
next
response.Write testStr
%>
meizz 2003-12-13
  • 打赏
  • 举报
回复
<input onblur="if(value!=''&&/[^\u4E00-\u9FA5]+/.test(value)){alert('!!'); focus()}">
angelheavens 2003-12-13
  • 打赏
  • 举报
回复
/\W/
Tal 2003-12-13
  • 打赏
  • 举报
回复
<input onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\u4E00-\u9FA5]/g,''))">
潜水的鱼 2003-12-13
  • 打赏
  • 举报
回复
up

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧