【JavaScript】JS校验MAC地址

function validateMac() {
    var mac = "a1:b2:c3:d4:d5:e6";
    mac = mac.toUpperCase();
    var expre = /[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}/;
    var regexp = new RegExp(expre);
    if (!regexp.test(mac)) {
        alert("MAC地址错误或含有非法字符,请检查");
        return;
    }
}

你可能感兴趣的:(【JavaScript】JS校验MAC地址)