﻿function checktext(txt1)
         dim st
         st=" 〓＾＼１２３４５６７８９０～！＂＇·＃￥％……ˇ＠¨〈〉「」『』．‖々〃〔〕〖〗—（），。【】《》？；‘：“”［］｛｝—＋＝｜｀、《》~`!@#$%^&*()_+|-=\'?/<>{}[],.:;"
         dim i
         dim j
         for i=1 to len(st)
             for j=1 to len(txt1)
                 if mid(st,i,1)=mid(txt1,j,1) then
                    checktext=mid(st,i,1) 
                    exit function
                 end if
             next 
         next
         checktext=""
end function 

sub checkform()
    dim username
    dim password
    dim password1
    dim question
    dim answer
    dim email
    dim num1
    
    dim i
    dim j
    dim st1
    dim isok
    
    username=document.getElementById("TextBox1").value
    password=document.getElementById("TextBox2").value
    password1=document.getElementById("TextBox3").value
    answer=document.getElementById("TextBox4").value
    question=document.getElementById("TextBox5").value
    email=document.getElementById("TextBox6").value
    num1=document.getElementById("Textbox12").value
    
'=====================================================================================  
    if len(username)<4 or len(username)>7 then
       msgbox "会员登陆名必须由4-7个有效字符组成。",vbinformation,"agenow新生代社区提示"
       document.getElementById("TextBox1").focus
       exit sub
    end if
       
    username=lcase(username)
    
    dim checktext1
    
    checktext1=checktext(username)
    
    if checktext1<>"" then
       msgbox "会员登陆名不能包含非法字符串" & checktext1,vbinformation,"agenow新生代社区提示"
       document.getElementById("TextBox1").focus  
       exit sub         
    end if 
    
    if isnumeric(username)=true then
       msgbox "不能注册全部为数字的帐号!" ,vbinformation,"agenow新生代社区提示"
       document.getElementById("TextBox1").focus  
       exit sub 
    end if
'=====================================================================================
    if len(password)<6 or len(password)>20 then
       msgbox "密码由6-20个英文字母(区分大小写)或数字组成。",vbinformation,"agenow新生代社区提示"
       document.getElementById("TextBox2").focus
       exit sub
    end if
    
    for i=1 to len(password)
        st1=mid(password,i,1)
        isok=Isabc(st1)
        if isok=0 then isok=Is123(st1)
        if isok=0 then isok=IsABC1(st1)
        
        if isok<>1 then
           msgbox "密码由6-20个英文字母(区分大小写)或数字组成。",vbinformation,"agenow新生代社区提示"
           document.getElementById("TextBox2").focus
           exit sub
        end if              
    next
    
    if password1<>password then
       msgbox "二次输入的密码不相同。",vbinformation,"agenow新生代社区提示"
       document.getElementById("TextBox3").focus
       exit sub
    end if
    
    if username=password then
       msgbox "用户名和密码不能相同。",vbinformation,"agenow新生代社区提示"
       document.getElementById("TextBox2").value=""
       document.getElementById("TextBox3").value=""
       document.getElementById("TextBox2").focus
       exit sub
    end if
'=====================================================================================
    if question="" then
       msgbox "安全提问问题不能为空。",vbinformation,"agenow新生代社区提示"
       document.getElementById("TextBox5").focus
       exit sub
    end if
'=====================================================================================
    if answer="" then
       msgbox "安全提问答案不能为空。",vbinformation,"agenow新生代社区提示"
       document.getElementById("TextBox4").focus
       exit sub
    end if
'=====================================================================================
    if question=answer then
       msgbox "答案不能与问题相同。",vbinformation,"agenow新生代社区提示"
       document.getElementById("TextBox5").focus
       exit sub
    end if
'=====================================================================================
    if email="" then
       msgbox "邮箱将用于必要时取回密码，请一定填写真实。",vbinformation,"agenow新生代社区提示"
       document.getElementById("TextBox6").focus
       exit sub
    end if
    
    if IsValidEmail(email)=false then
       msgbox "无效的电子邮箱地址。",vbinformation,"agenow新生代社区提示"
       document.getElementById("TextBox6").focus
       exit sub
    end if
'===================================================================================== 
   if len(num1)<>5 then
      msgbox "请输入正确的验证码。",vbinformation,"agenow新生代社区提示"
      document.getElementById("TextBox12").focus
      exit sub
   end if    
    
   for i=1 to len(num1)
       st1=mid(num1,i,1)
       isok=Is123(st1)
       if isok<>1 then
          msgbox "请输入正确的验证码",vbinformation,"agenow新生代社区提示"
          document.getElementById("TextBox12").focus
          exit sub
       end if
   next     
   
   document.getElementById("Button1").click()
end sub

Function Isabc(st)
    dim j
    for j=97 to 122
        if st=chr(j) then
           Isabc=1
           exit function
        end if        
    next
    Isabc=0
End Function

Function IsABC1(st)
    dim j
    for j=65 to 90
        if st=chr(j) then
           IsABC1=1
           exit function
        end if        
    next
    IsABC1=0
End Function

Function Is123(st)
        dim j
        for j=0 to 9
            if cstr(st)=cstr(j) then
               Is123=1
               exit function
            end if 
        next
        Is123=0
End Function

Function IsValidEmail(Email) 
         dim ValidFlag
         ValidFlag = False 
         dim atCount
         dim atLoop
         dim atChr
         dim BadFlag
         dim tAry1
         dim UserName
         dim DomainName
         
         If (Email <> "") And (InStr(1, Email, "@") > 0) And (InStr(1, Email, ".") > 0) Then 
             atCount = 0 
             SpecialFlag = False 
             For atLoop = 1 To Len(Email) 
                 atChr = Mid(Email, atLoop, 1) 
                 If atChr = "@" Then atCount = atCount + 1 
                 If (atChr >= Chr(32)) And (atChr <= Chr(44)) Then SpecialFlag = True 
                 If (atChr = Chr(47)) Or (atChr = Chr(96)) Or (atChr >= Chr(123)) Then SpecialFlag = True 
                 If (atChr >= Chr(58)) And (atChr <= Chr(63)) Then SpecialFlag = True 
                 If (atChr >= Chr(91)) And (atChr <= Chr(94)) Then SpecialFlag = True 
             Next 
             If (atCount = 1) And (SpecialFlag = False) Then 
                BadFlag = False 
                tAry1 = Split(Email, "@") 
                UserName = tAry1(0) 
                DomainName = tAry1(1) 
                If (UserName = "") Or (DomainName = "") Then BadFlag = True 
                If Mid(DomainName, 1, 1) = "." then BadFlag = True 
                If Mid(DomainName, Len(DomainName), 1) = "." then BadFlag = True 
                ValidFlag = True 
                ' 格式正确返回Ture
             End If 
         End If 
         If BadFlag = True Then ValidFlag = False 
         ' 格式不正确返回False
         IsValidEmail = ValidFlag 
End Function 

sub getcode()
    document.getElementById("img1").src="/ValidateNumber.aspx?t=" & now()
end sub

sub checkname()
    dim username
    username=document.getElementById("TextBox1").value
    if len(username)<4 or len(username)>7 then
       msgbox "会员登陆名必须由4-7个有效字符组成。",vbinformation,"agenow新生代社区提示"
       document.getElementById("TextBox1").focus
       exit sub
    end if
       
    username=lcase(username)
    
    dim checktext1
    
    checktext1=checktext(username)
    
    if checktext1<>"" then
       msgbox "会员登陆名不能包含非法字符串" & checktext1,vbinformation,"agenow新生代社区提示"
       document.getElementById("TextBox1").focus  
       exit sub         
    end if 
    
    if isnumeric(username)=true then
       msgbox "不能注册全部为数字的帐号!" ,vbinformation,"agenow新生代社区提示"
       document.getElementById("TextBox1").focus  
       exit sub 
    end if

    document.getElementById("name1").value=username
    formhtml.submit()
end sub