function isNumber(val)
	if isNumeric(val.value) then
		isNumber = true
	else
		msgbox "This value must be numeric."
		val.select
		isNumber = false
	end if
end function

function isLength(val,valname)
	if len(trim(val.value))>0 then
		isLength = true
	else
		msgbox valname&"输入框不能为空"
		val.focus()
		isLength = false
	end if
end function

function isPhoneArea(val,valname)
	if isLength(val,valname) then
	if isNumeric(val.value) and len(val.value)>2 and len(val.value)<5 then
		isPhoneArea = true
	else
		msgbox "城市区号输入错误！"
		val.select
		isPhoneArea = false
	end if
	end if
end function

function isPhoneNumber(val,valname)
	if isLength(val,valname) then
if len(val.value)>6 then
		isok="0123456789-"
xx="0"
for i = 1 to len(val.value)
				for x = 1 to len(isok)
					if mid(val.value,i,1)=mid(isok,x,1) then
						xx="1"
						x=len(isok)+1
					end if
				next
if xx="0" then
xxx="1"
end if
if xx="1" then
xx="0"
end if
			next
		if xx="0" and xxx<>"1" then
			isPhoneNumber = true
		else
			msgbox valname&"输入框有非法字符！"
			val.select
			isPhoneNumber = false
		end if
else
		msgbox valname&"输入错误！请重新输入！"&chr(10)&"外地电话请在区号与电话号码之间加－"
		val.select
		isPhoneNumber = false
end if
	end if
end function

function isfax(val,valname)
	if val.value<>"" then
if len(val.value)>6 then
		isok="0123456789-"
xx="0"
for i = 1 to len(val.value)
				for x = 1 to len(isok)
					if mid(val.value,i,1)=mid(isok,x,1) then
						xx="1"
						x=len(isok)+1
					end if
				next
if xx="0" then
xxx="1"
end if
if xx="1" then
xx="0"
end if
			next
		if xx="0" and xxx<>"1" then
			isfax = true
		else
			msgbox valname&"输入框有非法字符！"
			val.select
			isfax = false
		end if
else
		msgbox valname&"输入错误！请重新输入！"&chr(10)&"外地电话请在区号与电话号码之间加－"
		val.select
		isfax = false
end if
else
		isfax = true
end if
end function

function isFaxArea(val,valname)
	if val.value<>"" then
	if isNumeric(val.value) and len(val.value)>2 and len(val.value)<5 then
		isFaxArea = true
	else
		msgbox "传真城市区号输入错误！"
		val.select
		isFaxArea = false
	end if
else
		isFaxArea = true
	end if
end function

function isZip(val)
	if val.value<>"" then
	if isNumeric(val.value) and len(val.value)=6 then
		isZip = true
	else
		msgbox "邮政编码输入错误！"
		val.select
		isZip = false
	end if
else
		isZip = true
	end if
end function

function isFaxNumber(val,valname)
	if val.value<>"" then
	if isNumeric(val.value) and len(val.value)>6 and len(val.value)<14 then
		isFaxNumber = true
	else
		msgbox "传真号码输入错误！"
		val.select
		isFaxNumber = false
	end if
else
		isFaxNumber = true
	end if
end function

function isMobilePhone(val,valname)
	if val.value<>"" then
	if isNumeric(val.value) and len(val.value)>9 and len(val.value)<14 then
		isMobilePhone = true
	else
		msgbox "移动电话号码输入错误！"
		val.select
		isMobilePhone = false
	end if
else
		isMobilePhone = true
	end if
end function

function isAddress(val,valname)
	if isLength(val,valname) then
if len(val.value)>4 and instr(val.value,"'")=0 and instr(val.value,"%")=0 and instr(val.value,">")=0 and instr(val.value,"<")=0 and instr(val.value,"!")=0 then
		isAddress = true
	else
		msgbox "街道地址输入有误或输入太简单！"
		val.focus()
		isAddress = false
	end if
	end if
end function

function isLength1(val)
	if len(trim(val.value))>0 then
		isLength1 = true
	else
		msgbox "输入框不能为空"
		val.focus()
		isLength1 = false
	end if
end function

function checklen(val,valname)
	if len(val.value)>3 and len(val.value)<21 then
		checklen = true
	else
		msgbox "您在"&valname&"输入框中输入的字符数与规定的不符！"
		val.focus()
		checklen = false
	end if
end function

function checklen1(val,valname)
	if len(val.value)>3 then
		checklen1 = true
	else
		msgbox "您在"&valname&"输入框中输入的字符数与规定的不符！"
		val.focus()
		checklen1 = false
	end if
end function

function isProperdate(val)
	if isDate(trim(val.value)) then
		isProperdate = true
	else
		msgbox "Please enter a valid date."
		val.select
		isProperdate = false
	end if
end function

function isCCnumber(val)
	if isLength(val) then
		ccnumber = false
		val.value = trim(replace(val.value," ",""))
		if isNumeric(val.value) then
			ccnum = val.value			for i = len(ccnum) to 2 step -2				total = total + cint(mid(ccnum,i,1))				tmp = cstr((mid(ccnum,i-1,1))*2)				total = total + cint(left(tmp, 1))				if len(tmp)>1 then
					total = total + cint(right(tmp,1))
				end if			next			if len(ccnum) mod 2 = 1 then
				total = total + cint(left(ccnum,1))
			end if
			if total mod 10 = 0 then				ccnumber = true			end if		end if
		if ccnumber then
			isCCnumber = true
		else
			msgbox "Please use a valid credit card number."
			val.select
			isCCnumber = false
		end if
	end if
end function

function isCCdate(val)
	if isLength(val) then
		ccdate = false
		if len(val.value)>=3 and len(val.value)<=5 then
			if instr(val.value,"/")>0 then
			   tCC = split(val.value,"/")
			   if isNumeric(tCC(0)) and isNumeric(tCC(1)) then
			      mn = cint(tCC(0))
			      yr = cint(tCC(1))
				   currYear = cint(right(year(date()),2))
				   if mn>0 and mn<13 then
				      if yr = currYear then
				         if mn >= month(date()) then
				            ccdate = true
				         end if
				      else
				         if yr<currYear+4 then
				            ccdate = true
				         end if
				      end if
				   end if
				end if
			end if
		end if
		if ccdate then
			isCCdate = true
		else
			msgbox "Please enter a valid expiry date."
			val.select
			isCCdate = false
		end if
	end if
end function


function isPositive(val)
	if isNumber(val) then
		if val.value>=0 then
			isPositive = true
		else
			msgbox "Please enter a positive number."
			val.select
			isPositive = false
		end if
	end if
end function

function isNegative(val)
	if isNumber(val) then
		if val.value<0 then
			isNegative = true
		else
			msgbox "Please enter a negative number."
			val.select
			isNegative = false
		end if
	end if
end function

function isnotAlpha(val,valname)
	if isLength(val,valname) then
if valname="“密码提示问题”" then
		isNot=" !@#$^*()_+=-'`~\|]}[{;:/.,<>&%"
else
		isNot="!@#$^*()_+=-'`~\|]}[{;:/.,<>&%?"
end if
		invalid = false
		if instr(val.value,chr(34))>0 then
			invalid=true
		else
			for i = 1 to len(val.value)
				for x = 1 to len(isNot)
					if mid(val.value,i,1)=mid(isNot,x,1) then
						invalid = true
					end if
				next
			next
		end if
		if not invalid then
			isnotAlpha = true
		else
			msgbox valname&"输入框有非法字符！"
			val.select
			isnotAlpha = false
		end if
	end if
end function
function isCity(val,valname)
	if isLength(val,valname) then
		isNot="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 !@#$^*()_+=-'`~\|]}[{;:/.,<>&%?"
		invalid = false
		if instr(val.value,chr(34))>0 then
			invalid=true
		else
			for i = 1 to len(val.value)
				for x = 1 to len(isNot)
					if mid(val.value,i,1)=mid(isNot,x,1) then
						invalid = true
					end if
				next
			next
		end if
		if not invalid then
			isCity = true
		else
			msgbox valname&"输入框有非法字符！"
			val.select
			isCity = false
		end if
if len(val.value)<2 then
			msgbox valname&"输入字符太少！"
			val.select
			isCity = false
end if
	end if
end function

function momncheck(val,valname)
	if val.value<>"" then
		isNot="!@#$^*_+='`~\|]}[{;:/.,<>%?"
		invalid = false
		if instr(val.value,chr(34))>0 then
			invalid=true
		else
			for i = 1 to len(val.value)
				for x = 1 to len(isNot)
					if mid(val.value,i,1)=mid(isNot,x,1) then
						invalid = true
					end if
				next
			next
		end if
		if not invalid then
			momncheck = true
		else
			msgbox valname&"输入框有非法字符！"
			val.select
			momncheck = false
		end if
if len(val.value)<2 then
			msgbox valname&"输入字符太少！"
			val.select
			momncheck = false
end if
else
momncheck = true
	end if
end function

function isAlpha(val,valname)
	if isLength(val,valname) then
		isok="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
xx="0"
for i = 1 to len(val.value)
				for x = 1 to len(isok)
					if mid(val.value,i,1)=mid(isok,x,1) then
						xx="1"
						x=len(isok)+1
					end if
				next
if xx="0" then
xxx="1"
end if
if xx="1" then
xx="0"
end if
			next
		if xx="0" and xxx<>"1" then
			isAlpha = true
		else
			msgbox valname&"输入框有非法字符！"
			val.select
			isAlpha = false
		end if
	end if
end function

function checkpwd(val,valname)
	if isLength(val,valname) then
		isok="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"
xx="0"
for i = 1 to len(val.value)
				for x = 1 to len(isok)
					if mid(val.value,i,1)=mid(isok,x,1) then
						xx="1"
						x=len(isok)+1
					end if
				next
if xx="0" then
xxx="1"
end if
if xx="1" then
xx="0"
end if
			next
		if xx="0" and xxx<>"1" then
			checkpwd = true
		else
			msgbox valname&"输入框有非法字符！"
			val.select
			checkpwd = false
		end if
	end if
end function


function isEmail(val)
if len(val.value)>0 then
		isok="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@.~_-"
xx="0"
for i = 1 to len(val.value)
				for x = 1 to len(isok)
					if mid(val.value,i,1)=mid(isok,x,1) then
						xx="1"
						x=len(isok)+1
					end if
				next
if xx="0" then
xxx="1"
end if
if xx="1" then
xx="0"
end if
			next
e = val.value
charsplit=split(e,"@")
for each ele in charsplit
mm=mm+1
if mm=1 and instr(ele,".")>0 then
emailerr=1
end if
if ele="" then
emailerr=1
end if
next
if mm>2 then
emailerr=1
end if
		if instr(e,"@")>0 and instr(e,".")>0 and instr(e,"@.")=0 and instr(e,".@")=0 and len(e)>5 and xxx<>"1" and emailerr<>"1" and right(e,1)<>"." then
			isEmail = true
		else
			msgbox "请输入正确的Email地址！"
			val.select
			isEmail = false
		end if
else
isEmail = true
end if
end function

function isbakEmail(val)
	if val.value<>"" then

		isok="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@.~_-"
xx="0"
for i = 1 to len(val.value)
				for x = 1 to len(isok)
					if mid(val.value,i,1)=mid(isok,x,1) then
						xx="1"
						x=len(isok)+1
					end if
				next
if xx="0" then
xxx="1"
end if
if xx="1" then
xx="0"
end if
			next
e = val.value
charsplit=split(e,"@")
for each ele in charsplit
mm=mm+1
if mm=1 and instr(ele,".")>0 then
emailerr=1
end if
if ele="" then
emailerr=1
end if
next
if mm>2 then
emailerr=1
end if
		if instr(e,"@")>0 and instr(e,".")>0 and instr(e,"@.")=0 and instr(e,".@")=0 and len(e)>5 and xx="0" and xxx<>"1" and emailerr<>"1" and right(e,1)<>"." then
			isbakEmail = true
		else
			msgbox "请输入正确的Email地址！"
			val.select
			isbakEmail = false
		end if
else
isbakEmail = true
	end if
end function

function isPath(val)
	if isLength(val) then
		path = false
		if instr(val.value,":\")>0 then
			isNot=" !@#$^*()'`~|]}[{;.>,<?%&+="
			path = true
			if instr(val.value,chr(34))>0 then
				path = false
			else
				for i = 1 to len(val.value)
					for x = 1 to len(isNot)
						if mid(val.value,i,1)=mid(isNot,x,1) then
							path = false
						end if
					next
				next
			end if
		end if
		if path then
			isPath = true
		else
			msgbox "Please enter a valid local path."
			val.select
			isPath = false
		end if
	end if
end function

function isURL(val)
	if val.value<>"" and val.value<>"http://" then

		isok="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789:.-/~`#$%&_"
xx="0"
for i = 1 to len(val.value)
				for x = 1 to len(isok)
					if mid(val.value,i,1)=mid(isok,x,1) then
						xx="1"
						x=len(isok)+1
					end if
				next
if xx="0" then
xxx="1"
end if
if xx="1" then
xx="0"
end if
			next
e = val.value
		if instr(e,"http://")>0 and instr(e,".")>0 and len(e)>10 and xx="0" and xxx<>"1" and right(e,1)<>"." then
			isURL = true
		else
			msgbox "请输入正确的网址,以http://开头！"
			val.select
			isURL = false
		end if
else
val.value=""
isURL= true
	end if
end function

function isPwdSome(val1,val2)
	if val1.value=val2.value then
		isPwdSome=true
	else
		msgbox "两次输入的密码必须相同"
			val2.select
			isPwdSome = false
	end if
end function
