JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text"/>
JavaScript
$('input').on('change keyup keydown',function(){
var txt = $(this).val();
$(this).val(/^[ABCEGHJ-NPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][ -]?\d[ABCEGHJ-NPRSTV-Z]\d$/i.test(txt)&txt.length<10?txt:txt.substring(0,txt.length-1));
});