<!--#INCLUDE FILE="Md5.asp" -->
<!--#INCLUDE FILE="validate.asp" -->

<%
function chkinput()

	dim biryear,birmonth,birday
	Dim oicq,email,telephone,mobilephone,msn
	Dim address,zipcode,realname,maxim
	dim ErrMsg,FoundErr,oldanswer

	If chkpost=false then
		ErrMsg=ErrMsg+"<Br>"+"<li>您提交的数据不合法，请不要从校友录外部提交信息。"
		Call top(1,1)
		Call Error("Critical",ErrMsg)
		chkinput=false
		exit function
	End If

	userpwd=request.Form("userpwd")
	userpwd1=request.Form("userpwd1")
	If not (userpwd="" and userpwd1="") then
		If userpwd<>userpwd1 then
			ErrMsg=ErrMsg+"<br>"+"<li>您两次输入的密码不相同！"
			FoundErr=true
		ElseIf strlength(userpwd)<6 or strlength(userpwd)>12 then 
			ErrMsg=ErrMsg+"<br>"+"<li>密码长度必需为6-12个字符！"
			FoundErr=true
		ElseIf isValidstring(userpwd)<>"" then
		If isValidstring(userpwd)=" " then invld="空格" Else invld=isValidstring(userpwd)
		ErrMsg=ErrMsg+"<br>"+"<li>密码中含有非法字符&nbsp;<font color=#cc0000>"&invld&"</font>&nbsp;。"
			FoundErr=true
		ElseIf userpwd=membername then
			ErrMsg=ErrMsg+"<br>"+"<li>密码不能和用户名相同！"
			FoundErr=true
		End If
	End If

	question=trim(request.Form("question"))
	answer=trim(request.Form("answer"))
	oldanswer=request.Form("oldanswer")
	If question="" and answer<>"" or question<>"" and answer="" then
		ErrMsg=ErrMsg+"<br>"+"<li>取回密码时的提示问题和答案必需同时输入，如果不想使用此功能请留空!"
		FoundErr=true
	ElseIf answer<>"" and question<>"" then
'
		If strlength(question)<6 or strlength(question)>20 then
			ErrMsg=ErrMsg+"<br>"+"<li>取回密码提示问题不能少于6个字符或多余20个字符!"
			FoundErr=true
		ElseIf isValidstring(question)<>"" then
			If isValidstring(question)=" " then invld="空格" Else invld=isValidstring(question)
			ErrMsg=ErrMsg+"<br>"+"<li>密码提示问题中含有非法字符&nbsp;<font color=#cc0000>"&invld&"</font>&nbsp;。"
		FoundErr=true
		End If

		If strlength(answer)<6 or strlength(answer)>20 then
			ErrMsg=ErrMsg+"<br>"+"<li>取回密码答案不能少于6个字符或多余20个字符!"
			FoundErr=true
		ElseIf isValidstring(answer)<>"" then
			If isValidstring(answer)=" " then invld="空格" Else invld=isValidstring(answer)
			ErrMsg=ErrMsg+"<br>"+"<li>取回密码答案中含有非法字符&nbsp;<font color=#cc0000>"&invld&"</font>&nbsp;。"
			FoundErr=true
		End If
		
		if answer<>oldanswer then
			If question=answer then
				ErrMsg=ErrMsg+"<br>"+"<li>取回密码答案不能和提示问题相同!"
				FoundErr=true
			ElseIf answer=membername then
				ErrMsg=ErrMsg+"<br>"+"<li>取回密码答案不能和用户名相同!"
				FoundErr=true
			End If
		end if

	End If

	realname=trim(request.Form("realname"))
	If realname="" or strLength(realname)<4 or strLength(realname)>8 then
		ErrMsg=ErrMsg+"<br>"+"<li>请输入真实姓名（4-8个字符）。"
		FoundErr=true
	ElseIf not isChinese(realname) then
		ErrMsg=ErrMsg+"<br>"+"<li>请用中文输入真实姓名。"
		FoundErr=true
	End If

	biryear=request.Form("year")
	If len(biryear)<>4 or not isInteger(biryear) then
		ErrMsg=ErrMsg+"<br>"+"<li>生日年份应为四位数字!"
		FoundErr=true
	Else
		biryear=cint(biryear)
		If biryear>cint(year(date)) or biryear<(cint(year(date))-60) then
			ErrMsg=ErrMsg+"<br>"+"<li>请输入正确的用户出生年份！"
			FoundErr=true
		End If
	End If

	birmonth=request.form("month")
	birday=request.form("day")
	birthday=biryear&"-"&birmonth&"-"&birday
	if not isdate(birthday) then
		errmsg=errmsg+"<br>"+"<li>生日输入有误！"
		founderr=true
	else
		birthday=cdate(birthday)
	end if

	email=trim(request.Form("email"))
	If email="" then
		ErrMsg=ErrMsg+"<br>"+"<li>邮件地址不能为空。"
		FoundErr=true
	ElseIf not isValidEmail(email) then
		ErrMsg=ErrMsg+"<br>"+"<li>电子邮件地址输入有误！"
		FoundErr=true
	End If
		
	oicq=trim(request.Form("oicq"))
	If oicq<>"" and (len(oicq)<4 or len(oicq)>11 or not isinteger(oicq)) then
		ErrMsg=ErrMsg+"<br>"+"<li>QQ号码输入有误！"
		FoundErr=true
	End If

	msn=trim(request.Form("msn"))

	If msn<>"" and not isValidEmail(msn) then
		ErrMsg=ErrMsg+"<br>"+"<li>MSN号码输入有误！"
		FoundErr=true
	End If

	homepage=trim(request.Form("homepage"))
	If homepage<>"" and homepage<>"http://" and left(homepage,7)<>"http://" then
	homepage="http://"&homepage
	End If

	telephone=trim(request.Form("telephone"))
	If telephone<>"" and not IsValidTel(telephone) then
		ErrMsg=ErrMsg+"<br>"+"<li>电话号码输入错误"
		FoundErr=true
	End If

	mobilephone=trim(request.form("mobilephone"))
	if mobilephone<>"" and (len(mobilephone)<>11 or not isinteger(mobilephone) or left(mobilephone,2)<>"13") then
		errmsg=errmsg+"<br>"+"<li>移动电话输入错误"
		founderr=true
	end If

	zipcode=trim(request.Form("zipcode"))
	address=trim(request.Form("address"))
	If address<>"" and zipcode="" then
		ErrMsg=ErrMsg+"<br>"+"<li>请输入邮政编码"
		FoundErr=true
	End If

	If zipcode<>"" and (len(zipcode)<>6 or not isinteger(zipcode)) then
		ErrMsg=ErrMsg+"<br>"+"<li>邮政编码输入错误"
		FoundErr=true
	End If

	maxim=request.Form("maxim")

	If strlength(maxim)>320 then
		ErrMsg=ErrMsg+"<br>"+"<li>个性签名不能大于320个字符。"
		FoundErr=true
	else
		mline=split(maxim,vbCrLf)
		if ubound(mline)>8 then
			ErrMsg=ErrMsg+"<br>"+"<li>个性签名不能多于8行。"
			FoundErr=true
		end if
	End If

	If FoundErr=true then
		Call top(1,1)
		Call Error("Information",ErrMsg)
		chkinput=false
	Else
		if userpwd<>"" then userpwd=md5(userpwd)
		if answer<>"" and answer<>oldanswer then answer=md5(answer)
		chkinput=true
	End If

End function
%>
