I am looking to create an input field that automatically removes entered characters if they do not match a specific pattern.
Here is the template:
<input
type="text"
:value="val"
@input="input"
/>
And here is the script:
import { ref } from "vue";
export default {
setup() {
let val = ref("");
const input = ({ target }) => {
val.value = target.value.replace(/[^\d]/g, "");
};
return { val, input };
},
};
You can view the sandbox here.