JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<input type="text" id="promocode" placeholder="xxxx-xxx" />
<div id="result">Enter value (8-digits)</div>
JavaScript
$("#promocode").on('change keydown paste input propertychange click keyup blur', function(){
if($('#promocode').val().length == 8){
$("#result").html('okay');
}
else{
$("#result").html('not okay');
}
})