0

LWC lightnig input type date max value dynamically I'm trying to add max Date as 2 years from now. Getting the error ass add_years is not defined

Any suggestion would be great..

Html:

<lightning-input class="dateBoxWidth" type="date" date-style="short" value={select.recordValue} onchange={handleChnage} min={todayDate} max={renewExpiryDate}></lightning-input>


<lightning-input class="dateBoxWidth" type="date" date-style="short" value={select.recordValue} onchange={handleChnage} min={todayDate} max={renewExpiryDate}></lightning-input>

js:

var newDate = new Date(); 
        this.todayDate = newDate.toLocaleDateString();
var ExpiryDate = new Date();
        this.renewExpiryDate = add_years(ExpiryDate, 2).toLocaleDateString();
2
  • 1
    Where is the add_years() defined? If you have defined it at class level, then call it using this. – rahul gawale Oct 18 '20 at 8:42
  • I didn't used it or defined anywhere except in above place .. Please suggest in code.. I'll understand.. Thank you for reply @rahulgawale – Jairam Oct 18 '20 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.