JSFiddle - React, Tailwind, and code Playground
HTML
Escriba su cĂłdigo: <input type = "text" id = "codigo" />
JavaScript
var pattern = /\d/,
caja = document.getElementById("codigo");
caja.addEventListener("keypress", function(e){
if (this.value.length === 0 && (!(/(E|V)/).test(String.fromCharCode(e.keyCode))))
e.preventDefault();
if (this.value.length > 0 && (!pattern.test(String.fromCharCode(e.keyCode)) || this.value.length == 10))
e.preventDefault();
if (this.value.length === 1)
this.value += "-";
}, false);