'***************************************************************************************************
'***************************************************************************************************
'* Template: VB_Validation.vbs																	   *	
'* Author: SergTu 															   *	
'* Description: VB Functions for validating form data								  					   *	
'* Date Last Modified: 4 JAN 2001																   *	
'***************************************************************************************************

'**************** Email validating ***************************************
function isEmail(string)
if string="" Then 
	isEmail=False
end if
Set Reg = new Regexp
Reg.Pattern = "(^([a-z0-9_-])+)@([a-z0-9\._-]*)\.([a-z]{2,3})$"
' Now only 3 -chars last domain name are allowed. If you want allow
' 4 symbols in main domain name then previous string should be:
' Reg.Pattern = "(^([a-z0-9_-])+)@([a-z0-9\._-]*)\.([a-z]{2,3,4})$"
Reg.IgnoreCase = True
Reg.Global = True
Set Matches = reg.Execute(string)   
if  Matches.Count > 0 Then 
	isEmail= TRUE
else 
	isEmail= False
end if
end function
'******************Checking for being numeric ****************************
function isNum (string)
if string="" Then 
	isNum = False
end if
Set Reg = new Regexp
Reg.Pattern = "^(([0-9])+)$"
Reg.IgnoreCase = True
Reg.Global = True
Set Matches = reg.Execute(string)   
if  Matches.Count > 0 Then 
	isNum= TRUE
else 
	isNum= False
end if
end function
'******************Checking that string consists not less than intLowLimit characters**********
function isNotLess (string, intLowLimit)
if len(string)>intLowLimit Then
	isNotLess = TRUE
else 
	isNotLess=FALSE
end if
end function
'*************** Checking for avoiding special characters ****************************

function isName (string)
if string="" Then 
	isName=False
end if
Set Reg = new Regexp
Reg.Pattern = "^((\w)([\w-_\.@])*)$"
Reg.IgnoreCase = True
Reg.Global = True
Set Matches = reg.Execute(string)   
if  Matches.Count > 0 Then 
	isName= TRUE
else 
	isName= False
end if
end function
'*************** Checking for phones ****************************

function isPhone (string)
if string="" Then 
	isPhone=False
end if
Set Reg = new Regexp
Reg.Pattern = "^(([\d-\+\(\)\s])*)$"
Reg.IgnoreCase = True
Reg.Global = True
Set Matches = reg.Execute(string)   
if  Matches.Count > 0 Then 
	isPhone= TRUE
else 
	isPhone= False
end if
end function