Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

231
Vistas
How to use HTML5 validation check for inputs in Vuejs

How to use html5 form.checkValidity() with form of custom components in vuejs 2?

With html5 inputs, form validation works well:

<form name="myform" ref="formref">
  <input type="text" required /> 
  <button type="submit" @click="submitForm">Ok</button>
</form>
...
methods: {
  submitForm() {
    if (this.$refs.formref.checkValidity()) sendData();
    else showError();
  }
}

But if I use custom components, that won't work:

<form name="myform" ref="formref">
  <MyCustomInputComponent :required="true" /> 
  <button type="submit" @click="submitForm">Ok</button>
</form>

checkValidity() of the form will always return true.

The question, is how should I implement MyCustomInputComponent to let it works with HTML5 forms validation?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I see two options:

  1. Trying to validate the custom field inside the component. For this I would use @keyup event to fire the validation before submition. If you are using vuetify (it is a very common library) you can use the rules tag to do it.

  2. Use an external library called veeValidate for this.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda