You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
docuseal/app/javascript/elements/visible_on_input.js

15 lines
420 B

export default class extends HTMLElement {
connectedCallback () {
this.input = document.getElementById(this.dataset.inputId)
this.input.addEventListener('input', () => {
if (this.input.value.trim().length > 0) {
this.classList.remove('hidden')
} else {
this.classList.add('hidden')
this.querySelectorAll('input').forEach(input => { input.value = '' })
}
})
}
}