会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
互联网、我来了! 我很乖!
没人会因为你可怜而给予你想要的----咬着牙微笑!
js验证表单输入必须为汉字
js验证表单输入必须为汉字
<
script
>
function
checkchinese()
{
var
reg
=
/
[^\x00-\x80]
/
;
var
x
=
document.namefrom.xing.value;
if
(
!
reg.test(x))
{
alert(
"
请输入汉字!
"
);
document.namefrom.xing.focus();
document.namefrom.xing.value
=
""
;
return
false
;
}
var
m
=
document.namefrom.ming.value;
if
(
!
reg.test(m))
{
alert(
"
请输入汉字!
"
);
document.namefrom.ming.focus();
document.namefrom.ming.value
=
""
;
return
false
;
}
}
<
/
script>
<
form name
=
"
namefrom
"
method
=
"
post
"
action
=
"
index.php
"
onSubmit
=
'
return checkchinese();
'
>
<
input type
=
text name
=
"
xing
"
>
<
input type
=
text name
=
"
ming
"
>
<
input type
=
"
submit
"
value
=
"
检查
"
>
<
/
form>
用正则表达式/[\u4E00-\u9FA5]/表示中文
posted on
2009-05-25 10:54
5201314
阅读(
6244
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
导航
博客园
首页
新随笔
联系
订阅
管理
公告