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

80
Vistas
angular two validations fire in the same time

I validate my angular form using below code

       <div class="form-group">
                <input type="text" minlength="12" maxlength="12" name="accountno" #accountNo="ngModel" required class="form-control"  pattern="^[0-9]*$"
                [(ngModel)]="registerUser.accountNo"    [class.is-invalid]="accountNo.invalid && accountNo.touched"
                placeholder="Account No.">
                <div [class.d-none]="accountNo.valid || accountNo.untouched">
                    <small *ngIf="accountNo.errors?.required" class="text-danger">Account No. is required</small>
                    <small *ngIf="accountNo.hasError('pattern')" class="text-danger">Accout No. should be 12 numbers</small>
                    <small *ngIf="accountNo.hasError('minlength')" class="text-danger">Accout No. must be at least 12 Numbers.</small>
                </div>
            
            </div>

When I typing letters in the textbox, two validations fire in same time. please check below image

enter image description here

how i load my validations one by one.. thanks

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

0

This is the correct behavior, since the text you provided is not a valid number and it has less than 12 characters.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Use NgSwitch instead of ngIf and some function call that returns the first key of formControl.errors object I think it can help

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