Created
May 10, 2023 00:24
-
-
Save andrewjcurrie/b3fb4a56585e649214d135a897e6df73 to your computer and use it in GitHub Desktop.
IPv4 Address Validator
This file contains 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 ValidateIPaddress(inputText) { | |
var ipformat = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/; | |
if (inputText.value.match(ipformat)) { | |
alert("You entered a valid IPv4 address."); | |
document.ipform.ipaddr.focus(); | |
return false; | |
} else { | |
alert("You entered an invalid IPv4 address."); | |
document.ipform.ipaddr.focus(); | |
return false; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment