JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" maxlength="11" name="text" /><label for="text">(19 or 20)-###-#### format required</label>
JavaScript
$('input').on('keyup', function (event) {
var newValue = this.value.replace(/[^0-9\-]/gi, '');
if (this.value != newValue) {
this.value = newValue;
}
}).on('blur', function () {
if (this.value.search(/[(20)(19)](-)([0-9]{3})(-)([0-9]{4})/gi) == -1) {
alert('ERROR!');
} else {
alert('GOOD GOING!');
}
});