Skip to content

Instantly share code, notes, and snippets.

@arth2o
Created November 19, 2015 11:32
Show Gist options
  • Save arth2o/f27adefafffdc8cdd8fc to your computer and use it in GitHub Desktop.
Save arth2o/f27adefafffdc8cdd8fc to your computer and use it in GitHub Desktop.
JavaScript regexp ip validation
function validateIp(ipaddress)
{
if (/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/.test(ipaddress))
{
return (true)
}
return (false)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment