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

139
Vistas
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 Respuestas
Responde la pregunta

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 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