JSFiddle - React, Tailwind, and code Playground
by KelseyW
HTML
<div>
<input type="text" maxlength="2" class="day-spin-month"></input>
<span>/</span>
<input type="text" maxlength="2" class="day-spin-day"></input>
<span>/</span>
<input type="text" maxlength="4" class="day-spin-year"></input>
</div>
JavaScript
$('.day-spin-month, day-spin-day, day-spin-year').on('keyup', function () {
this.value = this.value.replace(/[^0-9\.]+/g, '');
});
$('.day-spin-month').on('keyup', function () {
if (this.value.length >= 2) {
$(this).next('input').focus();
}
});
$('.day-spin-day').on('keyup', function () {
if (this.value.length >= 2) {
$(this).next('input').focus();
}
});