<% '********************************************************* ' VP-ASP 4.50 Validate vatnumber ' June 2, 2002 '********************************************************* Sub Validatevat (strcountry) dim vatmycountry, partial setsess "vatnumber","" dim vatnumber, vatrc vatnumber=request("vatnumber") If vatnumber <> "" then ShopvalidateVat strcountry, vatnumber, vatrc select case vatrc case 0 vatmycountry=getconfig("xvatcountry") if strcountry<>vatmycountry then setsess "vatnumber",vatnumber end if case 4 sError = sError & LangVatinvalid & " " & vatnumber & "
" end select end if End sub '********************************************************* ' VP-ASP 4.50 April 7, 2002 ' Validate VAT '****************************************************** Sub ShopValidateVat(country, vatnumber, rc) dim tmpcountry, tmpvat, partial tmpvat = ucase(replace(vatnumber," ", "")) tmpcountry = left(vatnumber,2) If tmpcountry=country then tmpvat=right(tmpvat, len(vatnumber) - 2) end if select case country case "AT" if len(tmpvat) = 9 then if left(tmpvat, 1) = "U" then rc = 0 else rc = 4 end if else rc = 4 end if case "BE" if len(tmpvat) = 9 And IsNumeric(tmpvat) then rc = 0 else rc = 4 end if case "DK" if len(tmpvat) = 8 And IsNumeric(tmpvat) then rc = 0 else rc = 4 end if case "FI" if len(tmpvat) = 8 And IsNumeric(tmpvat) then rc = 0 else rc = 4 end if case "FR" rc=4 if len(tmpvat) <> 11 then exit sub partial=mid(tmpvat,3,9) If not isnumeric(partial) then exit sub rc=0 case "UK" if len(tmpvat) = 9 And IsNumeric(tmpvat) then rc = 0 else rc = 4 end if case "DE" if len(tmpvat) = 9 And IsNumeric(tmpvat) then rc = 0 else rc = 4 end if case "EL" if len(tmpvat) = 9 And IsNumeric(tmpvat) then rc = 0 else rc = 4 end if case "IE" if len(tmpvat) = 9 and not isnumeric(tmpvat) then rc = 0 else rc = 4 end if case "IT" if len(tmpvat) = 11 And IsNumeric(tmpvat) then rc = 0 else rc = 4 end if case "LU" if len(tmpvat) = 8 And IsNumeric(tmpvat) then rc = 0 else rc = 4 end if case "NL" if len(tmpvat) = 12 And left(right(tmpvat, 3), 1) = "B" And IsNumeric(right(tmpvat,2)) then rc = 0 else rc = 4 end if case "PT" if len(tmpvat) = 9 And IsNumeric(tmpvat) then rc = 0 else rc = 4 end if case "ES" if len(tmpvat) = 9 And IsNumeric(left(right(tmpvat, 8),7)) then rc = 0 else rc = 4 end if case "SE" if len(tmpvat) = 12 And IsNumeric(tmpvat) And right(tmpvat, 2) = "01" then rc = 0 else rc = 4 end if case else 'Set country to "" and return invalid country code error rc=8 end select end sub %>