Date format in lightning-input after changed input value format

datelightning-web-componentslightninginputvalidation

An issue in Date format validation in lightning-input type Date: After I changed the input value format according to the latest Salesforce updated ICU locale format for Ireland.
enter image description here

The last column shows the latest format above the last line.

The error I'm getting:

enter image description here

The code that supplies the date value:

JS:

this._DOBLife1 = '30/04/1964';
const dobparts = this._DOBLife1.split('/');
this._DOBLife1 = dobparts[0] + ' ' + 'Apr' + ' ' + dobparts[2];

HTML:

<lightning-input name="life1_DOB" value={_DOBLife1} class="fieldvalidateterm" type="date" label="DOB"  variant="label-inline" required ></lightning-input>

Best Answer

Value attribute should be in YYYY-MM-DD format. On view based on locale you can see same date in different formats.

Update js code as below.

 this._DOBLife1 = '30/04/1964';
 const dobparts = this._DOBLife1.split('/');
 this._DOBLife1 =  dobparts[2] + '-' + dobparts[1] + '-' + dobparts[0];//Notice this

Refer this article for more info on dates.

Related Topic