JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" id="purchases" value="1"/>
<div id="amount"></div>
<div id="message"></div>

JavaScript

function check_value(val) {
   if(val > 10){
       val = 10;
       $(this).val(10);
       $('#message').text("no more than 10");
          
   }
   $('#amount').text(val * 10);    
}

check_value($('input#purchases').val());

$('#purchases').keydown(function(e){
   if(!(e.which >= 48 && e.which <=58) && e.which !== 8 && e.which !== 46 && e.which !== 37 && e.which !== 39){ //prevent anything other than numeric characters, backspace, delete, and left & right arrows
       return false;
   }
})
.keyup(function(){
 check_value($(this).val());
});