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

272
Vistas
Disable input text field which are coming on future month in angular

i have static table columns for each month and static table body columns as input text for each month.i am having a problem in creating logic to disable future month input text. thank in advance code of my html file

i want to disable input of future month for example november and december

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

0

in angular you can use the property [disabled] on input field and call a component a method

for sample you can create a method and pass in parameter the monthNumber

<input [disabled]="isFutureMonth(0)"/> // for january
<input [disabled]="isFutureMonth(1)"/> /// for febrary

and in the component's controller we can propose you to :

  1. stored somewhere the current month

  2. create a method that check if input month is in the future or not enter code here

    export class MyComponent {

     currentMonth:number;
    
     constructor() {
       this.currentMonth = new Date().getMonth();
     }
    
     isFutureMonth(monthNumber:number):boolean {
       return (monthNumber > this.currentMonth);
     }
    

    }

about 4 years ago · Juan Pablo Isaza Denunciar

0

You need to add additional field in your static table for monthNumber. For ex: Jan = 1, Feb = 2, Mar = 3.....

After that in you component declare two new variable todaysDate = todaysDate: Date = new Date(); and currentMonth = currentMonth: any

Then create method to get current month as below

getMonth() {
    this.month = this.todaysDate.getMonth() + 1;
}

Call this method from ngOnInit(), you will get current month.

After this in your HTML file add [disabled] in your input fields [disabled]="(i.month > currentMonth)"

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