Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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();
   }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #input #number #vue
ADD COMMENT
Topic
Name
2+4 =