[Vuejs]-How to prevent the character "e" from being pasted on in the input field in vue js

0👍

Instead preventing that two things separately, you can just replace all "e" characters with an empty string:

<template>
  <div>
    <input type="text" v-model="text" />
    <div>Value is: {{ text }}</div>
  </div>
</template>

<script>
import { ref, watchEffect } from "vue";

export default {
  setup() {
    const text = ref("");

    watchEffect(() => {
      text.value = text.value.replace(/e/, "");
    });

    return { text };
  },
};
</script>

Demo:

https://codesandbox.io/s/prevent-e-character-lzi1o

Leave a comment