⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 checkusername.txt

📁 ajax技术书籍 ajax技术书籍
💻 TXT
字号:
Name: 用户名检查函数
Author: shemily
Create: 2007-04-29
Version: 1.0
Language: VBscript

<%
'------------参数说明-------------
'checkName	--需要检查的用户名
'table		--用户名所保存的表名
'fieldName	--用户名的字段名
'---------------------------------
function checkUserName(checkName, table, fieldName)
	Response.Expires = -1
	Response.ExpiresAbsolute = Now() - 1
	Response.cachecontrol = "no-cache"
	
	dim backStr,con,rs
	
	if(checkName="") then						'if userName is null
		backStr = "Err_101"
	else
		'wrong username check
		Set re = New RegExp
		re.Pattern = "^\d{1}.*"
		if(re.Test(checkName)) then				'if userName start with a number
			backStr = "Err_103"
		else
			re.Pattern = "[\- \+ \\ \/ \& ! ~ @ # \$ % \^ \* \( \) = \? '  \< \> \. , : ; \] \[ \{ \} \|]"
			if(re.Test(checkName)) then			'if userName include some no letter
				backStr = "Err_104"
			else
				set con=getConn()
				set rs=getRs()
				sql="select top 1 * from "&table&" where "&fieldName&"='"&checkName&"'"
				rs.open sql,con,1,1
	
				if not rs.bof and not rs.eof then	'if userName is not exists
					backStr = "Err_100"
				else					'if userName is exists
					backStr = "Err_102"
				end if
	
				rs.close
				con.close
				set rs=nothing
				set con=nothing
			end if
		
		end if
	
	end if
	
	checkUserName = backStr		'return error code
	
end function
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -