JSFiddle - React, Tailwind, and code Playground
HTML
<input class="dateValue" name="" id="" />
<input type="submit" value="Submit" />
JavaScript
$(function() {
$('input.dateValue').bind('focusout', function(e) {
if(! this.value.match(/\d{4}$/) ) {
console.log('aa');
e.preventDefault();
//.attr('value','');
$(this).focus().val('');
}
});
});