Modificare il file:
\iwgallery\WA_ValidationToolkit\WAVT_Scripts_VB.asp
<% '----------------------------------------------------------------------------- '- File Name: '- WAFV_Scripts_JS.asp '- '- Description: '- Shared functions for WA Form Validations - Server Side ASP JavaScript '- '- This file contains proprietary and confidential information from WebAssist.com '- corporation. Any unauthorized reuse, reproduction, or modification without '- the prior written consent of WebAssist.com is strictly prohibited. '- '- Copyright 2004 WebAssist.com Corporation. All rights reserved. '-----------------------------------------------------------------------------*/ function PostResult(thePage,theErrors,valPage) dim SessionVal SessionVal = "" for each variable_name in request.form SessionVal = SessionVal & "WAVT_" & variable_name & "=" & request.form(variable_name) & "&" next SessionVal = SessionVal & "WAVT_" & valPage & "=" & Right(theErrors,Len(theErrors)-1) Session("WAVT_"&valPage) = SessionVal Response.Redirect(thePage) end function Function IIf( expr, truepart, falsepart ) IIf = falsepart If expr Then IIf = truepart End Function function WAtrimIt(theString,leaveLeft,leaveRight) if (NOT leaveLeft) then theString = LTrim(theString) end if if (NOT leaveRight) then theString = RTrim(theString) end if WAtrimIt = theString end function function WAValidateAN(value,allowUpper,allowLower,allowNumbers,allowSpace,extraChars,required,number) dim WAFV_ErrorMessage, isValid WAFV_ErrorMessage = "" isValid = true for x=1 to Len(value) dim charGood, nextChar, charCode charGood = false nextChar = Mid(value,x,1) charCode = Asc(Mid(value,x,1)) if (allowLower) then if (charCode >= 97 AND charCode <= 122) then charGood = true end if end if if (allowUpper) then if (charCode >= 65 AND charCode <= 90) then charGood = true end if end if if (allowNumbers) then if (charCode >= 48 AND charCode <= 57) then charGood = true end if end if if (allowSpace) then if (nextChar = " ") then charGood = true end if end if if (extraChars <> "") then if (InStr(Replace(extraChars,""",""""),(nextChar)) > 0) then charGood = true end if end if if (NOT charGood) then isValid = false x = Len(value) end if Next if (required AND value="") then isValid = false if (NOT isValid) then WAFV_ErrorMessage = WAFV_ErrorMessage & "," & number end if WAValidateAN = WAFV_ErrorMessage end function function WAValidateCC(value,allow,required,number) dim WAFV_ErrorMessage, isValid, accepted WAFV_ErrorMessage = "" isValid = true accepted = ".- " & Chr(9) & Chr(10) & Chr(13) if (NOT (NOT required AND value = "")) then dim stripVal stripVal = "" for x=1 to Len(value) if (Asc(Mid(value,x,1))>=48 AND Asc(Mid(value,x,1))<=57) then stripVal = stripVal & Mid(value,x,1) else if (inStr(accepted,Mid(value,x,1))=0) then isValid = false end if end if next if (isValid) then if (allow<>"") then isValid = false allow = split(allow,":") for y=0 to UBound(allow) if (inStr(stripVal,allow(y))=1) then isValid = true exit for end if next end if end if if (isValid) then isValid = WA_isCreditCard(stripVal) end if end if if (NOT isValid) then WAFV_ErrorMessage = WAFV_ErrorMessage & "," & number end if WAValidateCC = WAFV_ErrorMessage end function function WA_isCreditCard(CardNumber) Dim theNumber, theMultiplier, theTotal, theDigit, thePosition, theSum WA_isCreditCard = False theTotal = 0 if Len(CardNumber) < 13 Then Exit function if Len(CardNumber) > 16 Then Exit function While Not Len(CardNumber) = 16 CardNumber = "0" & CardNumber Wend For thePosition = 1 To 16 theDigit = Mid(CardNumber, thePosition, 1) theMultiplier = 1 + (thePosition Mod 2) theSum = theDigit * theMultiplier if theSum > 9 Then theSum = theSum - 9 theTotal = theTotal + theSum Next WA_isCreditCard = ((theTotal Mod 10) = 0) End function function WAValidateDT(value,doDate,dateFormatStr,dateMin,dateMax,doTime,timeFormatStr,timeMin,timeMax,required,number) dim WAFV_ErrorMessage, isValid, timeFormat, dateFormat, dateVar Set timeFormat = New RegExp timeFormat.IgnoreCase = True timeFormat.Pattern = timeFormatStr Set dateFormat = New RegExp dateFormat.IgnoreCase = True dateFormat.Pattern = dateFormatStr WAFV_ErrorMessage = "" isValid = true if (NOT (NOT required AND value = "")) then if (doDate) then if (dateFormatStr <> "") then if (NOT dateFormat.test(value)) then isValid = false end if end if if (isValid) then dim compareDay if (NOT isDate(value)) then isValid = false else dateVar = cDate(value) end if if (dateMin <> "") then if (NOT isDate(dateMin)) then compareDay = eval(Replace(dateMin,""","""")) else compareDay = cDate(dateMin) end if if (dateVar < compareDay) then isValid = false end if if (dateMax <> "") then if (NOT isDate(dateMax)) then compareDay = eval(Replace(dateMax,""","""")) else compareDay = cDate(dateMax) end if if (dateVar > compareDay) then isValid = false end if end if end if if (doTime) then dim Today, enterTime, minTime if (timeFormatStr <> "") then if (NOT timeFormat.test(value)) then isValid = false end if end if if (InStr(value,":")=0) then isValid = false end if if (isValid) then dim fullYear if (NOT isDate(value)) then if (isDate("1/1/1 " & value)) then dateVar = cDate("1/1/1 "& value) else isValid = false end if else dateVar = cDate(value) end if fullYear = datePart("yyyy",dateVar) if (timeMin <> "") then if (NOT isDate("1/1/1 " & timeMin)) then Today = eval( Replace(timeMin,""","""")) else Today = cDate("1/1/1 " & timeMin) end if enterTime = (datePart("h",dateVar)*360) + (datePart("n",dateVar)*60) + datePart("s",dateVar) minTime = (datePart("h",Today)*360) + (datePart("n",Today)*60) + datePart("s",Today) if (enterTime < minTime) then isValid = false end if if (timeMax <> "") then if (NOT isDate("1/1/1 "+timeMax)) then Today = eval(Replace(timeMax,""","""")) else Today = cDate("1/1/1 "+timeMax) end if enterTime = (datePart("h",dateVar)*360) + (datePart("n",dateVar)*60) + datePart("s",dateVar) maxTime = (datePart("h",Today)*360) + (datePart("n",Today)*60) + datePart("s",Today) if (enterTime > maxTime) then isValid = false end if end if end if if (NOT isValid) then WAFV_ErrorMessage = WAFV_ErrorMessage & "," & number end if end if WAValidateDT = WAFV_ErrorMessage end function function WAValidateEM(value,required,number) dim WAFV_ErrorMessage, isValid, counter WAFV_ErrorMessage = "" isValid = true if (NOT(NOT required AND value = "")) then dim accepted, quotedUser, ipDomainPat, section, userName, domainName, domArr set knownDomsPat = New RegExp knownDomsPat.Pattern = "^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$" set emailPat = New RegExp emailPat.Pattern = "^(.+)@(.+)$" accepted = "[^\s\(\)><@,;:\\""\.\[\]]+" quotedUser = "(""[^\""]*"")" set ipDomainPat = New RegExp ipDomainPat.Pattern = "^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$" section = "(" & accepted & "|" & quotedUser & ")" set userPat = New RegExp userPat.Pattern = ("^" & section & "(\." & section & ")*$") set domainPat = New RegExp domainPat.Pattern = ("^" & accepted & "(\." & accepted & ")*$") set theMatch = emailPat.execute(value) set acceptedPat = New RegExp acceptedPat.Pattern = ("^" & accepted & "$") userName = "" domainName = "" if (theMatch.Count = 0) then isValid = false else userName = Left(theMatch.Item(0).value, InStr(theMatch.Item(0).value,"@")-1) domainName = Right(theMatch.Item(0).value, Len(theMatch.Item(0).value) - InStr(theMatch.Item(0).value,"@")) domArr = Split(domainName,".") set IPArray = ipDomainPat.execute(domainName) for x=1 to Len(userName) if (asc(mid(userName,x,1)) > 127) then isValid = false end if next for x=1 to Len(domainName) if (asc(mid(domainName,x,1)) > 127) then isValid = false end if next if (not userPat.test(userName)) then isValid = false end if if (IPArray.Count > 0) then counter = 0 for Each x in IPArray if (x.value > 255) then isValid = false end if counter = counter + 1 if (counter >=4) then exit for end if next end if for x=0 to UBound(domArr) if (Not acceptedPat.test(domArr(x)) OR Len(domArr(x)) < 2) then isValid = false end if next if (Len(domArr(UBound(domArr))) <> 2 AND not knownDomsPat.test(domArr(UBound(domArr)))) then isValid = false end if if (UBound(domArr) < 1) then isValid = false end if end if end if if (NOT isValid) then WAFV_ErrorMessage = WAFV_ErrorMessage & "," & number end if WAValidateEM = WAFV_ErrorMessage end function function WAValidateEL(value,minLength,maxLength,required,number) dim WAFV_ErrorMessage, isValid WAFV_ErrorMessage = "" isValid = true if (NOT(NOT required AND value = "")) then if ((Len(value) < minLength) OR (Len(value) > maxLength AND maxLength > 0)) then isValid = false end if end if if (NOT isValid) then WAFV_ErrorMessage = WAFV_ErrorMessage & "," & number end if WAValidateEL = WAFV_ErrorMessage end function function WAValidateFE(value,extensions,required,number) dim WAFV_ErrorMessage, isValid, ExtensionArr WAFV_ErrorMessage = "" isValid = true extensions = Replace(extensions,", ",",") ExtensionArr = Split(extensions,",") if (NOT (NOT required AND value = "")) then isValid = false if (InStr(value,".") > 1) then value = Right(value,Len(value)-InStrRev(value,".")+1) for n=0 to UBound(ExtensionArr) ExtensionArr(n) = Replace(ExtensionArr(n)," ","") if (LCase(value) = LCase(ExtensionArr(n))) then isValid = true end if next end if end if if (NOT isValid) then WAFV_ErrorMessage = WAFV_ErrorMessage & "," & number end if WAValidateFE = WAFV_ErrorMessage end function function WAValidateLE(value1,value2,required,number) dim WAFV_ErrorMessage, isValid WAFV_ErrorMessage = "" isValid = true if (value1 <> value2 OR (required AND value1 = "")) then isValid = false end if if (NOT isValid) then WAFV_ErrorMessage = WAFV_ErrorMessage & "," & number end if WAValidateLE = WAFV_ErrorMessage end function function WAValidateNM(value,minLength,maxLength,allowDecimals,punctuationMarks,required,number) dim WAFV_ErrorMessage, isValid, theThousand, theDecimal, theCheck, trueDecimal, startVal, decimalIndex WAFV_ErrorMessage = "" isValid = true theThousand = Mid(punctuationMarks,1,1) theDecimal = Mid(punctuationMarks,2,1) theCheck = (11/10) trueDecimal = Mid(cStr(theCheck),2,1) startVal = cStr(value) decimalIndex = Len(value)+1 if (InStr(punctuationMarks,trueDecimal) = 0 AND InStr(value,trueDecimal) > 0) then isValid = false end if if (InStrRev(value,theDecimal)>0) then decimalIndex = InStrRev(value,theDecimal) end if while (InStr(value,theThousand)>0) decimalIndex = Len(value)+1 if (InStrRev(value,theDecimal)>0) then decimalIndex = InStrRev(value,theDecimal) end if if ((decimalIndex-(InStrRev(value,theThousand)+1)) Mod 3 <> 0) then isValid = false end if value = Left(value,InStrRev(value,theThousand)-1) + Right(value,Len(value)-InStrRev(value,theThousand)) wend if (trueDecimal <> theDecimal) then value = Replace(value,theDecimal,trueDecimal) end if if (NOT (NOT required AND value = "")) then dim oldVal for x=1 to Len(value) if ((Mid(value,x,1)<"0" OR Mid(value,x,1) > "9") AND (Mid(value,x,1) <> " " AND Mid(value,x,1) <> "," AND Mid(value,x,1) <> "." AND Mid(value,x,1) <> "-")) then isValid = false end if next if (value = "") then isValid = false end if oldVal = cStr(value) if (InStr(oldVal,trueDecimal)>0) then while ((Right(oldVal,1) = "0" OR Right(oldVal,1) = trueDecimal) AND InStr(oldVal,trueDecimal)>0) oldVal = Left(oldVal,Len(oldVal)-1) wend if (InStr(oldVal,trueDecimal) = 1) then oldVal = "0" & oldVal end if end if if (NOT isNumeric(value)) then isValid = false else value = cDbl(value) if (Len(cStr(value)) <> Len(cStr(oldVal))) then isValid = false else if (minLength > value OR maxLength < value) then isValid = false else if (cStr(allowDecimals) <> "") then if (InStr(startVal,theDecimal)>0 AND ((InStr(startVal,theDecimal) + allowDecimals + 1) <= Len(startVal) OR allowDecimals = 0)) then isValid = false end if end if end if end if end if end if if (NOT isValid) then WAFV_ErrorMessage = WAFV_ErrorMessage & "," & number end if WAValidateNM = WAFV_ErrorMessage end function function WAValidatePN(value,areaCode,international,required,number) dim WAFV_ErrorMessage, isValid, allowed, newVal, z WAFV_ErrorMessage = "" isValid = true allowed = "*() -./_+" & Chr(10) & Chr(13) newVal = "" if (NOT (NOT required AND value = "")) then for x=1 to Len(value) z = Mid(value,x,1) if ((z >= "0") AND (z <= "9")) then newVal = newVal & z else if (InStr(allowed,z) = 0) then isValid = false end if end if next if (international) then if (Len(newVal) < 5) then isValid = false end if else if (Len(newVal) = 11) then if (Left(newVal,1) <> "1") then isValid = false end if else if ((Len(newVal) <> 10 AND Len(newVal) <> 7) OR (Len(newVal)=7 AND areaCode)) then isValid = false end if end if end if end if if (NOT isValid) then WAFV_ErrorMessage = WAFV_ErrorMessage & "," & number end if WAValidatePN = WAFV_ErrorMessage end function function WAValidateRX(value,regExStr,required,number) dim WAFV_ErrorMessage, isValid, extraArgs WAFV_ErrorMessage = "" isValid = true extraArgs = Right(regExStr,Len(regExStr)-InStrRev(regExStr,"/")) regExStr = Mid(regExStr,InStr(regExStr,"/")+1,InStrRev(regExStr,"/")-InStr(regExStr,"/")-1) regExStr = Replace(regExStr,""","""") Set regEx = New RegExp regEx.IgnoreCase = (InStr(extraArgs,"i")>0) regEx.Pattern = regExStr if (NOT (NOT required AND value = "")) then dim theMatch theMatch = regEx.test(value) if (NOT theMatch) then isValid = false end if else if (required AND value = "") then isValid = false end if end if if (NOT isValid) then WAFV_ErrorMessage = WAFV_ErrorMessage & "," & number end if WAValidateRX = WAFV_ErrorMessage end function function WAValidateRQ(value,trimWhite,number) dim WAFV_ErrorMessage, isValid WAFV_ErrorMessage = "" isValid = true if (trimWhite) then value = Trim(value) end if if (isNull(value) OR value = "") then isValid = false end if if (NOT isValid) then WAFV_ErrorMessage = WAFV_ErrorMessage & "," & number end if WAValidateRQ = WAFV_ErrorMessage end function function WAValidateRT(value,notAllowed,required,number) dim WAFV_ErrorMessage, isValid, augValue, tempVal WAFV_ErrorMessage = "" isValid = true augValue = " " & LCase(value) & " " tempVal = augValue if (NOT (NOT required AND value="")) then dim notAllowedInfo, theIndex notAllowed = Split(notAllowed,", ") for x=0 to UBound(notAllowed) notAllowedInfo = Split(notAllowed(x),"|") notAllowedInfo(0) = Replace(notAllowedInfo(0),""","""") notAllowedInfo(1) = Replace(notAllowedInfo(1),""","""") if (InStr(tempVal,LCase(notAllowedInfo(0)))>0) then isValid = false exit for end if next end if if (required AND value="") then isValid = false end if if (NOT isValid) then WAFV_ErrorMessage = WAFV_ErrorMessage & "," & number end if WAValidateRT = WAFV_ErrorMessage end function function WAValidateSS(value,required,number) dim WAFV_ErrorMessage, isValid, allowed WAFV_ErrorMessage = "" isValid = true allowed = "*() -./_+" & Chr(10) & Chr(13) if (NOT (NOT required AND value = "")) then dim newVal, z newVal = "" for x=1 to Len(value) z = Mid(value,x,1) if ((z >= "0") AND (z <= "9")) then newVal = newVal & z else if (InStr(allowed,z) = 0) then isValid = false end if end if next if (Len(newVal) <> 9) then isValid = false end if end if if (NOT isValid) then WAFV_ErrorMessage = WAFV_ErrorMessage & "," & number end if WAValidateSS = WAFV_ErrorMessage end function function WAValidateUR(value,force,required,number) dim WAFV_ErrorMessage, isValid WAFV_ErrorMessage = "" isValid = true if (NOT (NOT required AND value="")) then if (LCase(force) = "none") then if (InStr(value,":")>0) then isValid = false end if end if if (InStr(value,"?") <> InStrRev(value,"?") OR InStr(value," ") > 0) then isValid = false end if if (isValid) then dim valURL valURL = value if (InStr(valURL,":")>0) then valURL = Right(valURL,Len(valURL)-InStr(valURL,":")) end if if (InStr(valURL,"?")>0) then valURL = Left(valURL,InStr(valURL,"?")) end if if (InStr(valURL,";") > 0 OR InStr(valURL,":") > 0 OR InStr(valURL,"&") > 0 OR InStr(valURL,"=") > 0 OR InStr(valURL,",") > 0) then isValid = false end if end if if (LCase(force) <> "false" AND LCase(force) <> "none" AND isValid) then force = Replace(force,", ",",") force = Split(force,",") isValid = false for x=0 to UBound(force) if (InStr(LCase(value),LCase(force(x)))=1) then isValid = true x = UBound(force) end if next end if end if if (required AND value="") then isValid = false end if if (NOT isValid) then WAFV_ErrorMessage = WAFV_ErrorMessage & "," & number end if WAValidateUR = WAFV_ErrorMessage end function function WAValidateZC(value,us5,us9,can6,uk,required,number) dim WAFV_ErrorMessage, isValid, allowed, hasLetters WAFV_ErrorMessage = "" isValid = true allowed = "() -." & Chr(13) & Chr(10) if (NOT (NOT required AND value="")) then dim newVal, charVal newVal = "" charVal = "" for x=1 to Len(value) z = Mid(value,x,1) if ((z >= "0") AND (z <= "9")) then newVal = newVal & z charVal = charVal & "N" else if (can6 AND (((z >= "a") AND (z <= "z")) OR ((z >= "A") AND (z <= "Z")))) then newVal = newVal & z charVal = charVal & "A" else if (InStr(allowed,z) = 0) then isValid = false end if end if end if next acceptPattern = "," if (us5) then acceptPattern = acceptPattern & "NNNNN," end if if (us9) then acceptPattern = acceptPattern & "NNNNNNNNN," end if if (uk) then acceptPattern = acceptPattern & "ANNAA,ANNNAA,AANNAA,AANNNAA,ANANAA,AANANAA," end if if (can6) then acceptPattern = acceptPattern & "ANANAN," end if if (InStr(acceptPattern,","&charVal&",") = 0) then isValid = false end if if (NOT isValid) then WAFV_ErrorMessage = WAFV_ErrorMessage & "," & number end if WAValidateZC = WAFV_ErrorMessage end function %>
[
Íàçàä
]