怎样判断vbscript输入的不是中文字符?
2个回答
展开全部
<script language="vbscript">
Function chk()
if userName.value="" then
msgbox("不能为空!")
userName.focus()
window.event.returnValue=false
exit function
end if
dim str,re,rv,Match
str=userName.value
Set re = New RegExp
re.Pattern="^[\u4e00-\u9fa5]*$"
re.Global=True
set rv=re.Execute(str)
For Each Match in rv
RetStr =Match.Length
Next
if(RetStr=Empty) then
msgbox("姓名必须全为中文")
username.value=""
userName.focus()
window.event.returnValue=false
exit function
else
msgbox("正确")
end if
end Function
</script>
<input name="userName" type="text">
<input type="button" onclick="chk()" value="确定">
Function chk()
if userName.value="" then
msgbox("不能为空!")
userName.focus()
window.event.returnValue=false
exit function
end if
dim str,re,rv,Match
str=userName.value
Set re = New RegExp
re.Pattern="^[\u4e00-\u9fa5]*$"
re.Global=True
set rv=re.Execute(str)
For Each Match in rv
RetStr =Match.Length
Next
if(RetStr=Empty) then
msgbox("姓名必须全为中文")
username.value=""
userName.focus()
window.event.returnValue=false
exit function
else
msgbox("正确")
end if
end Function
</script>
<input name="userName" type="text">
<input type="button" onclick="chk()" value="确定">
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询