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

140
Visualizações
DatepickerInput defaultValue is not working

I'm working on a requirement to display current date in the date field.

In the below example, if I change defaultValue to value, I see the currentDate is being displayed on page load for date element. But even after selecting a different date, I see current date is getting displayed.

If I keep defaultValue, current date is not getting displayed. Could someone suggest on how to display currentDate on page load and the date can be changed if needed to any other date.

<
DatepickerInput
id = "run-now-date-range-from"
label = "Time frame from date"
isSrOnlyLabel = {
    true
}
name = "runNowOptions.dateRange.dateRangeFrom"
defaultValue = {
    currentDate
}
validate = {
    value => {
        let error = "";

        if (!validateDate(value)) {
            error = controllerData?.reportTemplates[selectedReportTemplateIndex]?.runNowOptions?.dateRange?.showFutureDate ?
                "Please enter a from date up to 46 days in the future." :
                "Please enter a from date.";
        }

        return error;
    }
}
settings = {
    {
        endDate: getDateRange(controllerData?.reportTemplates[selectedReportTemplateIndex]),
        startDate: controllerData?.reportTemplates[selectedReportTemplateIndex]?.runNowOptions?.dateRange?.showFutureDate ? "0d" : "",
    }
}
/>


import React, {
    InputHTMLAttributes
} from "react";
import {
    InputProps
} from "./utils/input-types";
export declare type DatepickerInputProps = InputHTMLAttributes < HTMLInputElement > & InputProps & {
    settings ? : any;
    microcopy ? : string;
    validate ? : (any: any) => string;
};
declare const DatepickerInput: React.FC < DatepickerInputProps > ;
export default DatepickerInput;
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

in javaScript there is a inbuild function Date()

you can give it a try


    const foo = new Date();
    //above statement will return the current date
    
    const foo = new Date(2022, 08, 22);
    //above statement will return the date 22/08/2022
    
    //so you can use variable to set the date value like below
    const foo = new Date(year, month , day);

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