The IsValidIP method is used to determine whether a string represents a properly formatted IP address.
IsValid = chObj.IsValidIP ipAddrAsStr
True if ipAddrAsStr represents a properly formatted IP address, or False if not.
Note: This method tests whether ipAddrAsStr contains 4 octets that are within the range of 0 to 255, with each 'octet separated by '.' characters, and contains only digits. Note that by definition here, a valid IP means that the string is formatted correctly, and not necessarily that the IP address represents a reachable node on the internet. For example, "220.127.116.11" is a valid IP address by format so this method returns True for this value, despite the fact that this is not a reachable IP address.
set chObj = Server.CreateObject("cyScape.countryObj")
isValid = chObj.IsValidIP "18.104.22.168"
'The following would all return false
isValid = chObj.IsValidIP "207.46.230" 'does not contain 4 octets
isValid = chObj.IsValidIP "22.214.171.124a" 'contains non-numeric chars
isValid = chObj.IsValidIP "2126.96.36.199" ' cannot be greater than 255
isValid = chObj.IsValidIP "" ' cannot be blank
Tip: Before calling the Initialize method, use the IsValidIP method to make sure the IP address is valid. Otherwise the Initialize method will raise a run-time error that needs to be caught.
Tip: See the ch_initialize.asp sample for more information.
See the ch_initialize.asp sample for more information.
About the Properties and Methods Guide
About the sample scripts