JS judge verify the MAC address of the 2 instances
- 2020-03-30 02:48:06
- OfStack
Method one:
var temp = /[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}/;
if (!temp.test(document.mac.value))
{
return false;
}
Method 2:
function macFormCheck(mac)
{
var macs = new Array();
macs = mac.split(":");
if(macs.length != 6){
alert(" The input of mac The address format is incorrect, please use xx:xx:xx:xx:xx:xx Form input ( xx for 16 Base number) !");//A web - based online tutorial http: s _yige.org/js/
return false;
}
for (var s=0; s<6; s++) {
var temp = parseInt(macs[s],16);
if(isNaN(temp))
{
alert(" The input of mac The address format is incorrect, please use xx:xx:xx:xx:xx:xx Form input ( xx for 16 Base number) !");
return false;
}
if(temp < 0 || temp > 255){
alert(" The input of mac The address format is incorrect, please use xx:xx:xx:xx:xx:xx Form input ( xx for 16 Base number) !");
return false;
}
}
return true;
}