Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

147
Visualizações
max and min not working on custom input component in VueJS

I developed a custom input component, when I try to use it on a parent component, default input attributes max and min do not work. Here is my custom input element on the parent component

text-field(v-model="level" type="number" max="9" min="0" label="User Level" @beforeinput="onKeyup")

I saw that max and min not working that's why I wrote a function for the beforeInput event to prevent the user enter a number bigger than 9 and a string

 onKeyup(event: InputEvent) {
  const el = event.target as HTMLInputElement
  const value = +el.value
  console.log(value)
  if (value < 0 || value > 9) event.stopImmediatePropagation()
}

This function prevents users from entering string values but does not prevent users to enter a number bigger than 9. How can I fix this?

PS: I am using VueJS 3

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda