Hi,
I'm writing some basic forms for work, for collecting data, and I am just onto validating my forms now. One of the fields is Mac Address. I'm no expert on php and a colleague at work told me about regular expressions. Excellent I thought, I did some reading and came up with the following :
However it doesn't work.... I can't seem to get it to work. I've even tried some other "pre-made" expressions, for mac address', but they don't work either
Sitepoint : Suppost to validate with either ":" or "-"
Have I done anything stupid either with my simple if statement or is my expression wrong?
Any help would be greatly appreciated!
JB
I'm writing some basic forms for work, for collecting data, and I am just onto validating my forms now. One of the fields is Mac Address. I'm no expert on php and a colleague at work told me about regular expressions. Excellent I thought, I did some reading and came up with the following :
PHP:
<?php
$mac = "00:19:e3:01:56:47";
if (eregi("$([a-z0-9]{2})\:{5}([a-z0-9]{2})^", $mac, $mac_add)) {
echo $mac;
} else {
echo "Invalid mac address: $mac";
}
?>
However it doesn't work.... I can't seem to get it to work. I've even tried some other "pre-made" expressions, for mac address', but they don't work either
Sitepoint : Suppost to validate with either ":" or "-"
PHP:
(?<![-0-9a-f:])([\da-f]{2}[-:]){5}([\da-f]{2})(?![-0-9a-f:])
Have I done anything stupid either with my simple if statement or is my expression wrong?
Any help would be greatly appreciated!
JB