Skip to content

Instantly share code, notes, and snippets.

@mrklein
Created December 1, 2014 17:31
Show Gist options
  • Save mrklein/07249c2e80c27f476ca4 to your computer and use it in GitHub Desktop.
Save mrklein/07249c2e80c27f476ca4 to your computer and use it in GitHub Desktop.
Part of Bouygues Telecom Bbox web interface
function CheckIPString(Str,inCouldBeEmpty)
{
if (Str == "") return inCouldBeEmpty;
var regExpIP = new RegExp("^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}$");
if (!regExpIP.test(Str)) return false;
var ipArray = Str.split(".");
for (var i = 0; i < 4; i++) {
if ((Math.floor(ipArray[i]) < 0) || (Math.floor(ipArray[i]) > 247)) return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment