After doing some significant searching on whether there is some code for verifying an address already out there for VBScript it appears everyones answer is the same; use a premium service to test if the address actually exists. I didn’t want to do that, a) cause I don’t want to pay and b) cause there has to be a simple purifier that can do it via code. The result is the following code:
Function addinvalid(straddress)
'Set default value to False so we can only change if error
addinvalid = False
'Call the RegExpTest function with custom expression to test for
'non address characters
If RegExpTest("[\]\[!#$%&'()*+,./:;<=>?@\^_`{|}~-]",straddress) = True Then addinvalid = True
End Function
This is designed by be used with a function called RegExpTest which unfortunately I can’t post since I got it from a source that I don’t have copyrights to repost, however it shouldn’t be hard to reproduce.
All it does it take a Regular Expression, and a string to test and then returns True or False depending on whether Regular Expression was found.
This addinvalid function will return True if invalid or False if not.
The Regular Expression there is designed to find any characters that shouldn’t occur in an address. Obviously this solution isn’t perfect but it’s about as close as we’ll get without using a third-party verification program. Although might not be a bad idea to purify entry with this before sending to third-party program. 
No comments:
Post a Comment