<input type="date" id="dateInput" />
<p>Formatted Date: <span id="formattedDate"></span></p>
<script>
const dateInput = document.getElementById("dateInput");
const formattedDateSpan = document.getElementById("formattedDate");
dateInput.addEventListener("change", () => {
const [year, month, day] = dateInput.value.split("-");
formattedDateSpan.textContent = `${day}/${month}/${year}`; // Update on input
});
</script>
Post a Comment