Frameworks

Pick a framework below to see its install command and a full integration example. Every other page in these docs sticks to vanilla JS.

Vanilla JS

Bind native inputs after they exist, and dispose the bindings during teardown.

terminal
npm install mother-mask
index.html
<label for="phone">Phone</label>
<input id="phone" type="text" inputmode="tel" />
<label for="amount">Amount</label>
<input id="amount" type="text" inputmode="decimal" />

<script type="module">
  import { bind, bindDecimal } from 'mother-mask'

  const phone = document.getElementById('phone')
  const amount = document.getElementById('amount')
  const disposePhone = bind(phone, '(99) 99999-9999')
  const disposeAmount = bindDecimal(amount, { decimalPlaces: 2, prefix: '$' })

  // During teardown:
  // disposePhone()
  // disposeAmount()
</script>