Schemaphic Systems Blog

Sharing experiences in Flash, Flex and AIR

Check for valid IP Address

leave a comment »

function isValidIP(ip:String):Boolean {
ip = ip.replace( /\s/g, “”) //remove spaces for checking
var pattern:RegExp = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;

if (pattern.test(ip)) {
var octets:Array = ip.split(“.”);
if (parseInt(String(octets[0])) == 0) {
return false;
}
if (parseInt(String(octets[3])) == 0) {
return false;
}
for (var i=0; i 255){
return false;
}
}
return true;
} else {
return false;
}
return false;
}

Advertisements

Written by Deepanjan Das

July 12, 2010 at 9:08 PM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: