dynamic-input-mask

Developed for education and as a lightweight alternative to input masking libraries. Instead of building all of the masking functions this takes the approach of a utility/factory class. You can pass a broken RegExp to the constructed input array, and it will apply the necesary listeners to make the mask function.

Usage no npm install needed!

<script type="module">
  import dynamicInputMask from 'https://cdn.skypack.dev/dynamic-input-mask';
</script>

README

Dynamic Input JS

Developed for education and as a lightweight alternative to input masking libraries. Instead of building all of the masking functions this takes the approach of a utility/factory class. You can pass a broken RegExp to the constructed input array, and it will apply the necesary listeners to make the mask function.

Examples

const inputs = input(document.getElementById('weee'));
inputs.mask(
  [/[0-3]/, /\d/, /\d/, /\d/, /\-/, /[0-1]/, /\d/, /\-/, /[0-3]/, /\d/],
  ['', '', '', '', '-', '', '', '-', '', '']
);