Answers for "how to vue just number input"

2

number only input vue

<div id="demo">
  <input v-model="message" @keypress="isNumber($event)">
</div>
Posted by: Guest on February-16-2021
0

input will get only number vue

<input @keypress="onlyNumber" type="text">

onlyNumber ($event) {
   //console.log($event.keyCode); //keyCodes value
   let keyCode = ($event.keyCode ? $event.keyCode : $event.which);
   if ((keyCode < 48 || keyCode > 57) && keyCode !== 46) { // 46 is dot
      $event.preventDefault();
   }
}
Posted by: Guest on August-01-2021

Code answers related to "how to vue just number input"

Browse Popular Code Answers by Language