Technologies:
Tolerim
2 hours ago
How can I use the Cleave.js pattern to format dates in the DD.MM.YYYY format?
new Cleave('.my-input', {
date: true,
datePattern: ['Y', 'm', 'd'],
delimiter: '.'
}).on('change', function (event) {
var formattedValue = event.target.value.replace(/(\d{2}\.\d{2}\.\d{4})/, '$1.');
event.target.value = formattedValue;
});
Answers(1)
Tolerim
2 hours ago
Verified Answer
To add a trailing dot to the Cleave.js date pattern (DD.MM.YYYY.), you can modify the datePattern option in your Cleave.js code.
Here's an example:
new Cleave('.my-input', {
date: true,
datePattern: ['D', 'M', 'Y', '.'],
delimiter: '.'
});
In this example, we have added a period (.) after the 'Y' parameter in the datePattern. This will output the date format as DD.MM.YYYY. with the final dot.