Packages
Tailwind Live Components is a set of HEEX components that builds LiveView components with Tailwind 2.0+
Current section
Files
Jump to
Current section
Files
priv/static/hooks/zip_input.js
export default {
$valueInput: null,
mounted() {
this.$valueInput = this.el.querySelector('[data-tlc-ref="valueInput"]')
this.$valueInput.addEventListener("input", (event) => {
this.$valueInput.value = this.scrubInput(event.target.value)
this.$valueInput.dispatchEvent(new CustomEvent('change', { bubbles: true }));
})
this.scrubInput(this.$valueInput.value)
},
scrubInput(input) {
return input.replace(/\D/g, '').substring(0, 5).match(/^\d{0,9}$/)
}
}