日期:2014-05-16 浏览次数:20332 次
function macFormCheck(mac) {
var macs = new Array();
macs = mac.split("_");
if(macs.length != 6){
alert("The MAC you input is invalid!Please input a mac like xx_xx_xx_xx_xx_xx (xx should be sexadecimal number)! ");
isOK = 0 ;
return null ;
}
for (var s=0; s<6; s++) {
var temp = parseInt(macs[s],16);
if(macs[s].length > 2 ||macs[s].length < 2 )
{
alert("The MAC you input is invalid!Please input a mac like xx_xx_xx_xx_xx_xx (xx should be sexadecimal number)! ");
isOK = 0 ;
return null ;
}
if(isNaN(temp))
{
alert("The MAC you input is invalid!Please input a mac like xx_xx_xx_xx_xx_xx (xx should be sexadecimal number)! ");
isOK = 0 ;
return null;
}
if(temp < 0 || temp > 255 )
{
alert("The MAC you input is invalid!Please input a mac like xx_xx_xx_xx_xx_xx (xx should be sexadecimal number)! ");
isOK = 0 ;
return null ;
}
}
isOK = 1 ;
return mac;
}
function macFormCheck(mac) {
mac = mac + '';
if(/^[A-F\d]{2}(_[A-F\d]{2}){5}$/.test(mac))return mac;
alert("The MAC you input is invalid!Please input a mac like xx_xx_xx_xx_xx_xx (xx should be sexadecimal number)!");
return null
};
var ms = ['00_0F_12_AF_FF_FE', 'ab_0F_12_AF_FF_FE', '001_0F_12_AF_FF_FE'];
for(var i = ms.length - 1; i >= 0; i--)alert(ms[i] + '\r\n' + macFormCheck(ms[i]))
/^(?:[\da-f]{2,2}-){7,7}[\da-f]{2,2}$/i