This commit is contained in:
lchen committed 2024-01-17 17:31:41 +08:00
1 parent 84190ed9f1
commit fb9e920c15
35 files changed
+3003 -1304

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
export function validation(element, regex) {
if (element instanceof HTMLElement && regex instanceof RegExp) {
element.addEventListener('change', e => {
if (regex.test(e.target.value)) {
e.target.classList.remove('validation-error');
} else {
e.target.classList.add('validation-error');
}
})
}
return element;
}