Created
December 1, 2014 17:31
-
-
Save mrklein/07249c2e80c27f476ca4 to your computer and use it in GitHub Desktop.
Part of Bouygues Telecom Bbox web interface
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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