JSFiddle - React, Tailwind, and code Playground

by Hayk Aghabekyan

HTML

<input id="date" placeholder="DD.MM.YYYY" />

JavaScript

const input = document.getElementById('date');

input.addEventListener('input', (event) => {
	const value = event.target.value;
  const regExp = /^\s*(3[01]|[12][0-9]|0?[1-9])\.(1[012]|0?[1-9])\.((?:19|20)\d{2})\s*$/;
  
	if (regExp.test(value)) {
		alert(value);
  }
});