The vue.js input box forbids the entry of special characters

vue.js uses element-ui, in which < el-input > how to prohibit the input of special characters such as! @-sharp$% ^ &?


watch needs data to disable special characters, and update the variable watch in $nextTick () . The template is still v-model binds the fields that need to be entered.

for example, username :

  

listens for input events and, if there are these characters, replace them with empty characters

Menu