You need to sign in to do that
Don't have an account?
rushi
lwc reactivity
Hello All,
I have created a LWC component and part of that created new dates fields. In Js, I wrote the logic that when the selected date is below today's date then assign it to today's date and by default date should be today's date.
Issue: when the selected date is less than today's date then JS logic is executing and updating it to today's date but in UI it's not reflecting.
Example: When the page is loaded dafult date will be 4/27/2022 and when I select the date 4/20/2022, UI will display 4/20/2022 value and JS will hold the 4/27/2022 value.
<lightning-input type="date" data-id="date1" variant="label-hidden" placeholder="Enter Start Date.." value={date1} onchange={handleDateChange} ></lightning-input>
handleDateChange(event) {
let val = event.target.value;
const changedDate = val;
if(changedDate < this.today)
this.date1 = this.today;
}
I have created a LWC component and part of that created new dates fields. In Js, I wrote the logic that when the selected date is below today's date then assign it to today's date and by default date should be today's date.
Issue: when the selected date is less than today's date then JS logic is executing and updating it to today's date but in UI it's not reflecting.
Example: When the page is loaded dafult date will be 4/27/2022 and when I select the date 4/20/2022, UI will display 4/20/2022 value and JS will hold the 4/27/2022 value.
<lightning-input type="date" data-id="date1" variant="label-hidden" placeholder="Enter Start Date.." value={date1} onchange={handleDateChange} ></lightning-input>
handleDateChange(event) {
let val = event.target.value;
const changedDate = val;
if(changedDate < this.today)
this.date1 = this.today;
}
Please use below code:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh