vue input mobile phone number verification

Hits: 0

Vue [monitors] the disappearance of the input cursor to verify whether the mobile phone number is legal, and verify that the 11 digits of the regular mobile phone number start with 1

<input v-model= "phoneValue" @input= "handleInput(1)" type= "number"   @blur= "animate()" placeholder= "Please enter the phone number" max= "11" >

js code:

<script>
 export default {
 data(){
    return{
         phoneValue:""
    }
  }
  methods:{
       animate(){
           var re = /^1\d{10}$/;
           let str = this.phoneValue;
           if(re.test(str)){
               alert( 'success' )
           }else {
               alert( 'Sorry the phone number is invalid' )
          }
       }
  }
</script>

The above are some functional summaries and records of my work. Welcome to communicate with each other.

Leave a Reply

Your email address will not be published.