JSFiddle - React, Tailwind, and code Playground
HTML
<input id="demo" />
JavaScript
$('#demo').keyup( function(e) {
if(e.keyCode !== 8){
if( this.value.length == 3 || this.value.length == 7 ){
$(this).val(this.value+" ");
}
if( this.value.length == 11 ){
$(this).val(this.value+".");
}
}else{
if( this.value.length == 4 || this.value.length == 8 || this.value.length == 12 ){
//split sur la chaine - 1 caractère qu'on a ajouté
}
}
});