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; }