How I can allow typing in textarea only allowed digital numbers of lenght or license codes or product codes with different lengths or specific words only..
I've done research but there is only blacklist for words what you cant type or codes what you cant type.
But I want to whitelist what you can type and what codes or product codes you can type in textarea.
Whitelist I can make with PHP so words, codes, licenses are in database. And query them to javascript or jQuery.
Hardest part is JS or jQuery how to implement this.
Edit (allows only static codes and endings):
let values = event.target.value
.split('
')
.map(v => {
v = v.trim().toUpperCase();
if (v.length <= 16) { // static only 16 digits long codes allowed
if (CODE[0].substr(0, v.length) != v && // whitelist: const CODE = ["123456ASD", "654321DSA"];
CODE[1].substr(0, v.length) != v) {
v = v.substr(0, v.length - 1);
}
} else if (!v.substr(16, 22).match(reg)) { // static only 16 digits long and 6 digit long ending static
v = v.substr(0, v.length - 1);
}
return v;
}).join('
');
I want create like non static and for universal product code list and word list or license code list..