Home > Web Front-end > JS Tutorial > Two examples of JS judgment and verification of MAC address_javascript skills

Two examples of JS judgment and verification of MAC address_javascript skills

WBOY
Release: 2016-05-16 16:49:55
Original
1928 people have browsed it

Method 1:

Copy code The code is as follows:

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:
Copy code The code is as follows:

function macFormCheck(mac)
{
var macs = new Array();
macs = mac.split(":");


if(macs.length != 6){
alert("The entered mac address format is incorrect, please enter it in the form of xx:xx:xx:xx:xx:xx (xx is a hexadecimal number)! ");// Yiwang online tutorial http://yige.org/js/
return false;
}


for (var s=0; s<6; s ) {
var temp = parseInt(macs[s],16);

if(isNaN(temp))
{
alert("The entered mac address format is incorrect, please Enter in the form of xx:xx:xx:xx:xx:xx (xx is a hexadecimal number)!");
return false;
}


if(temp < 0 | );
return false;
}
}


return true;
}

Related labels:
js
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template