1.0.4 • Published 3 years ago
auto-format-input v1.0.4
auto-format-input
The text entered in the input field is formatted as you type based on the specified template.
Installation:
npm install auto-format-input
or
yarn add auto-format-input
There are two importable methods:
template($event, template, onylNumbers);
focus($event, target, after);
Using the template
and focus
together:
SomeFile.vue
<template> <form>
<label for="phone">Phone Number</label>
<input
type="text"
name="phone"
placeholder="(xx) xx/ xxx-xx-xx"
@keypress="[template($event, '(xx) xx/ xxx-xx-xx', true), focus($event, 'email', 18)]"
/>
<label for="phone">Email</label>
<input type="email" name="email" placeholder="email" />
<button>Submit</button>
</form>