<%
'*********************************************************
'文件名称: inc_valid.asp
'功能描述: 服务器端数据校验函数
'程序制作：叶开,阿泰
'官方网站: http://www.oblog.cn
'论坛支持：http://bbs.oblog.cn
'Copyright (C) 2004-2006 oblog.cn All rights reserved.
'LastUpdate:    200600501
'*********************************************************
'Check Boolean

Function Check01(sValue,sDefault)
	
	If (sValue="0" Or sValue="1") Then
		Check01=sValue
		Exit Function
	Else
		If sDefault="" Then
			Check01=""
			Exit Function
		Else
			Check01=sDefault
		End If
	End If
End Function

Function CheckInt(sValue,sDefault)
	CheckInt=sDefault
	If Not IsNumeric(sValue) Then Exit Function
	If InStr(sValue,".") Then Exit Function
	CheckInt=Int(sValue)
End Function

'Check Mail
Function IsValidEmail(email)
     Dim names, name, i, c
     IsValidEmail = True
     names = Split(email, "@")
     If UBound(names) <> 1 Then
		IsValidEmail = False
        Exit Function
     End If
     For Each name In names
		If Len(name) <= 0 Then
			IsValidEmail = False
            Exit Function
        End If
        For i = 1 To Len(name)
			c = LCase(Mid(name, i, 1))
            If InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 And Not IsNumeric(c) Then
               IsValidEmail = False
               Exit Function
            End If
        Next
        If Left(name, 1) = "." Or Right(name, 1) = "." Then
			IsValidEmail = False
            Exit Function
		End If
    Next
    If InStr(names(1), ".") <= 0 Then
		IsValidEmail = False
        Exit Function
    End If
    i = Len(names(1)) - InStrRev(names(1), ".")
    If i <> 2 And i <> 3 Then
		IsValidEmail = False
		Exit Function
    End If
    If InStr(email, "..") > 0 Then
		IsValidEmail = False
	End If
End Function

Function CheckStr(sValue,iLen,sMode)
	If IsNull(sValue) Then Exit Function
	'0:录入型
	If sMode=0 Then
		'检查恶意字符
		'检查禁止字符
		'检查长度
		If iLen<>"" Then CheckStr=Left(sValue,iLen)
	Else
		'输出型
		CheckStr=sValue
	End If
	
End Function
%>