ASP如何判断表单某项提交的值是否为中文,禁止提交除中文以外的任务字附

来源:百度知道 编辑:UC知道 时间:2024/05/31 06:58:43

<%
'******************************
'函数:CheckChinese(strng)
'参数:strng,待验证字符
'描述:检测是否为中文字符,返回值:中文为true,否则false
'示例:<%=CheckChinese(strng)%>
'******************************
Function CheckChinese(strng)
CheckChinese = true
Dim regEx, Match
Set regEx = New RegExp
regEx.Pattern = "\||\#|\&|\?|\@|\%|\*|\/|\.|\,|\;|\'|\:|\-|\_|\+|\^|\""|\=|\<|\>|\ "
regEx.IgnoreCase = True
Set Match = regEx.Execute(strng)
if match.count then CheckChinese= false
End Function

if CheckChinese(strng)=false then
response.write "请输入中文字符"
response.end
end if
%>

你可以在INPUTBOX里面写如下事件<input onKeyUp="value=value.replace(/[ -}]/g,'')">这样你的文本里面就只能写中文了