Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

273
Views
How to apply input which has type number in Vue.js?

I have made web apps using by Nuxt.js. I'm trying to apply for validation which excludes negative values and decimal points to all input tag(20~30) in same vue component. I think the way of injecting the validation rules to input tag on vue life-cycle mounted events goning to be success, but nothing change input tag.

<template>
・・・・・・・
<input
    type="number"
    style="width: 100%; box-sizing: border-box; text-align: right"
     v-model="item"
        />
・・・・・・・
</template>
<script lang="ts">
import { Component, Vue } from 'nuxt-property-decorator'
@Component({})
export default class extends Vue {
   onNumbers = (val: any) => {
    return val.replace(/\D/g, '')
  }

  mounted() {
    document.querySelectorAll('input').forEach((item) => {
      item.addEventListener('input', (val) => {
        this.onNumbers(val)
      })
    })
  }
}
</script>

Does anyone advise me?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In your input-tag set following properties to min="0" and step="1" and it should work.

<input
    type="number"
    min="0"
    step="1"
    style="width: 100%; box-sizing: border-box; text-align: right"
    v-model="item"
/>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!