When the el-input type is number, the non-numeric types are not completely restricted (the letters'e' and decimal points are allowed to be entered). What should I do?

phenomenon is described in the title,

the code is as follows:

<el-form-item label="" prop="first_channel_code">
   <el-input type="number" v-model.number="ruleForm.first_channel_code"></el-input>
</el-form-item> -sharp-sharp-sharp 

three ways:
1. Native

<el-input type="number" :min="0" v-model="form.zs" placeholder="()" clearable style="width:300px;" @keyup.native="form.zs = oninput(form.zs)">
<template slot="append"></template></el-input>

/ / filter two decimal places

oninput(val) {
  return val ? val.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3') : null
}

II. El-input-number tags included in elementui components
III. Regular verification of rules
phone: [

    {
        required: true,
        message: "",
        trigger: "blur"
    },
    {
        pattern: /^1[1-9]\d{9}$/,
        message: "",
        trigger: "blur"
    }
],

e and decimal point are also part of the number. This problem also exists in native input. If you want to completely solve this problem, you can only rely on js control


if you want to limit, you can listen for changes in watch to control non-numeric types.


the best compatibility is to write regularities in @ input, then add e letters or decimal points to filter


Thank you for sharing. Finally, it is solved by monitoring keyboard input events. The code is as follows:

<el-form-item label="" prop="first_channel_code">
  <el-input type="number" v-model.number="ruleForm.first_channel_code" @keydown.native="channelInputLimit"></el-input>
</el-form-item>

// bug fix:number'e''.'
channelInputLimit (e) {
  let key = e.key
  // 'e''.'
  if (key === 'e' || key === '.') {
    e.returnValue = false
    return false
  }
  return true
}
Menu