It turned out to be done only with the help of input , with a regular expression in the pattern attribute, where the length of the value becomes valid with 5 or more digits.
However, with the attribute disabled or readonly, the pseudo- class : valid does not work.
pointer-events: none;
helped pointer-events: none;
but cursor: pointer;
stopped working cursor: pointer;
and if you add an onclick event to input or wrap it in a label , the selection starts working
function set(value) { document.querySelector('input').value = value; }
input { width: 40px; height: 16px; background: #64bef0; color: #FFF; text-align: center; border-radius: 3px; padding: 3px 5px 3px 3px; font-size: 14px; outline: none; border: 0px; pointer-events: none; cursor: pointer; /* ( ◡́.◡̀) */ } input:valid { font-size: 12px; }
<input value='10000' pattern='\d{5,}' tabindex='-1'> <br><br> <button onclick='set(1000)'>1000</button> <button onclick='set(10000)'>10000</button>