The idea is to validate an IP address according to an IP address' format. This little bit of code uses regex to verify the range of the numbers and the format:
<?php
$ip = "255.255.255.255";
if (preg_match(
'/^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:[.](?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$/',$ip))
{
echo "IP valid.";
}
else
{
echo "IP invalid";
}
I used a similar method for validating an email address. Also using regex.
Posted 1 month ago #
You must log in to post.
.net address attributes browsers censored config css dates email validation filter firefox floor functions html ie ie fix image functions images input ip javascript links mail match math min-height min-width netscape opera php preloading print regex script smtp string styles textbox time validation variables visual basic