function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nagarajan CNagarajan C 

I have done the validation for my from date in lightning web components but it is not working current date

I have done the validation for my from date in lightning web components but it is not working current date.

current date also showing nvalidation if set min value as current date.so can you please help 
 
AbhinavAbhinav (Salesforce Developers) 
Hi Nagarajan,

Could you please give more clarification on your question with saome code snippet that you have tried.

Thanks!
Nagarajan CNagarajan C
Hi  Abhinav,

LWC 
JS
 connectedCallback(){
        var today = new Date();
        this.currentDate=today.toISOString();
        var defaultcurrent = new Date();
        this.minDate= defaultcurrent.toISOString();
}

Html
 <lightning-input type="date" name="fromDate" label="From Date" value={currentDate} min={minDate} ></lightning-input>

above code not working for if select current date gain means show vlaidation "Value must be Jun 10, 2021 or later."

But i selected Jun 10, 2021(today date(current date).

Can you please help here

Thanks
C.Nagarajan
Naveen KNNaveen KN
connectedCallback is like init method which is used to perform operation once the component is added to the DOM and before rendering to the UI. In your case you have to validate the date when you select it in input field. 

Add onchange handler in the input element
Add validation logic in the js file handler function out of connectedCallback() method.

try this and share the results. Thanks. 

Naveen K N