limit input to 2 decimal places jquery onchange event

I want when user enter a number into input field like this 54.78987, or any number more than two decimal places, it should automatically go back to two decimal places like 54.78. Function can be use on keyup or onchange event.

Answer

use parseFloat.ToFixed(2) for two decimal call.

$(document).ready(function(){
 
  $("#inpt").on('blur',function(){
      var currentObj=$(this);
      var currentVal= currentObj.val();
      if(!isNaN(currentVal)){
        var updatedVal=parseFloat(currentVal).toFixed(2);
        currentObj.val(updatedVal);
      }
      else{
          currentObj.val("");
      }
 })


})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="text" id="inpt"/>