Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!