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

275
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
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