description: a regular match is given to the content of an input box, and the matching content is the product activation code.
looks like this: "0C31-0B81-BB32-3094-0C31-0B81-BB32-3094"
Code:
$("-sharplicenseCode").keyup(function () {
let licenseCode = $(this).val();
let reg = /^([A-Z0-9]{4}-){7}[A-Z0-9]{4}$/g;
console.log(reg.test(licenseCode));
console.log(reg.test(licenseCode));
console.log(reg.test(licenseCode));
console.log(reg.test(licenseCode));
if (reg.test(licenseCode)) {
checkBtn.removeAttr("disabled");
console.log(11);
} else {
checkBtn.attr("disabled", "disabled");
console.log(22);
}
});
The result of input surprised me!
true,false,true,false
console.log();
:
I can"t figure it out! Why?