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

398
Vistas
HTML5 required attribute not working in Angular 2 project, installed using CLI

I am working on Angular 2 login page, when I try to validate input field with HTML 5 validate attribute required, it is not working, where as in the quick start project it works fine. Could any one explain why it is not working and how to resolve this issue ?

Plunker link of my code In Plunker, it validates but in my project its not working.

app.component.html code below,

<form class="login-form">
  <input type="text" name="usrname" placeholder="Username"  required/>

  <input type="password" name="pwd" placeholder="Password"  required>
  <input type="submit">

</form>
about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

As of version 4.0.0, Angular automatically adds "novalidate" to the form. Change this new default behavior by using:

<form ngNativeValidate>...</form>

Github issue here: https://github.com/angular/angular/issues/15531#issuecomment-289555359

about 4 years ago · Santiago Trujillo Denunciar

0

     <form class="login-form" novalidate> 
    <input type="text" name="usrname" placeholder="Username" required="required"> 
<input type="password" name="pwd" placeholder="Password" required="required"> 
<button type="submit">Submit </button> 
    </form> 

remove novalidate from your form tag to enable html5 validation

<form class="login-form" >

If you use novalidate in your form tag, the validation wont occur as that's that the novalidate keyword is for when you don't want the default html5 validation and you want to implement your own validation means you have to use the novalidate otherwise you don't need it

about 4 years ago · Santiago Trujillo 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