– Common Function Library Project


Last updated July 17, 2001


Nathan Dintenfass

Version: 1 | Requires: CF5 | Library: StrLib

Performs a regex on the string and determines if it a valid IP address. The value passed must match contain four octets delimited by a period. Each octet must be a number from 1 to 255. The addresses and are not valid. Note This only checks the octet form of IP addresses. It does not check the binary form.

Return Values:
Returns a boolean.


<CFSET BADIP = "fred">
<CFSET IP = "">
Is #BADIP# valid? #IsIP(BADIP)#<BR>
Is #BADIP2# valid? #IsIP(BADIP2)#<BR>
Is #IP# valid? #IsIP(IP)#<BR>


Name Description Required
string String to be checked. Yes

Full UDF Source:

 * Returns TRUE if the string is a valid IP address.
 * @param string      String to be checked. 
 * @return Returns a boolean. 
 * @author Nathan Dintenfass ( 
 * @version 1, July 17, 2001 
function isIP(ip){
    var ii = 1;
    //make sure it is a '.' delimited list 4 long
    if(listlen(ip,".") is not 4) return false;

    //make sure each item is a number between 1 and 255
    for(ii = 1;ii lte 4;ii = ii + 1){
        if(not isnumeric(listgetat(ip,ii,".")) OR listgetat(ip,ii,".") GT 255 OR listgetat(ip,ii,".") LT 0)    return false;
    //check for the special cases of or, which is not really valid
    if(ip is "" OR IP is "") return false;
    return true;


Latest Additions

Raymond Camden added
November 04, 2017

Leigh added
May 11, 2016

Raymond Camden added
May 10, 2016

Kevin Cotton added
May 05, 2016

Raymond Camden added
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson