»
AnglaisFran�aisVietnamien

Imprimer - Validation (IP Address) - JavaScriptBank.com

Version compl�te: jsB@nk » » Validation (IP Address)
URL: https://www.javascriptbank.com/validation-ip-address.html

Validation (IP Address) © JavaScriptBank.comVérifiez la valeur d'une adresse IP. Vérifiez pour les cas particuliers tels que 0.0.0.0 et 255.255.255.255. Cool!

Version compl�te: jsB@nk » » Validation (IP Address)
URL: https://www.javascriptbank.com/validation-ip-address.html



JavaScript
<SCRIPT LANGUAGE="JavaScript">// Jay Bienvenu<!-- Beginfunction verifyIP (IPvalue) {errorString = "";theName = "IPaddress";var ipPattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;var ipArray = IPvalue.match(ipPattern); if (IPvalue == "0.0.0.0")errorString = errorString + theName + ': '+IPvalue+' is a special IP address and cannot be used here.';else if (IPvalue == "255.255.255.255")errorString = errorString + theName + ': '+IPvalue+' is a special IP address and cannot be used here.';if (ipArray == null)errorString = errorString + theName + ': '+IPvalue+' is not a valid IP address.';else {for (i = 0; i < 4; i++) {thisSegment = ipArray[i];if (thisSegment > 255) {errorString = errorString + theName + ': '+IPvalue+' is not a valid IP address.';i = 4;}if ((i == 0) && (thisSegment > 255)) {errorString = errorString + theName + ': '+IPvalue+' is a special IP address and cannot be used here.';i = 4;      }   }}extensionLength = 3;if (errorString == "")alert ("That is a valid IP address.");elsealert (errorString);}//  End --></script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<form>IP Address:<input size=15 name="IPvalue"><input type="submit" value="Verify" onClick="verifyIP(IPvalue.value)";></form><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->