JSFiddle - React, Tailwind, and code Playground

HTML

<input id="numberBox" type="number" min="2" max="10" step="2" id="contact" />

JavaScript

$(function () {
   $( "#numberBox" ).change(function() {
      var max = parseInt($(this).attr('max'));
      var min = parseInt($(this).attr('min'));
      if ($(this).val() > max)
      {
          $(this).val(max);
      }
      else if ($(this).val() < min)
      {
          $(this).val(min);
      }       
    }); 
});