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

229
Views
How to prevent user from entering value below 1 in Vue 3 number input

I am attempting to set up a number input field in Vue 3 that prevents the user from entering a value below 1. So far I have the following input with min = 1 to prevent clicking the input arrows below 1:

<input min="1" type="number" />

However, the user can still manually enter 0 or a negative number. How can I prevent the user entering a number below 1?

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

0

You can check value on keyup:

const { ref } = Vue
const app = Vue.createApp({
  setup() {
    const numValue = ref(null)
    const setMin = () => {
      if(numValue.value < 1) numValue.value = null
    }
    return { numValue, setMin }
  },
})
app.mount('#demo')
<script src="https://unpkg.com/vue@3/dist/vue.global.prod.js"></script>
<div id="demo">
  <input @keyup="setMin" min="1" v-model="numValue" type="number" />
</div>

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!