Limit number in input text field and do calculation - Javascript jQuery

Javascript examples for jQuery:Form Number Field

Description

Limit number in input text field and do calculation

Demo Code

ResultView the demo in separate window


<html>
 <head> 
  <script src="https://code.jquery.com/jquery-latest.js"></script> 
 </head> //  w w w.j  av a 2  s . c  o m
 <body> 
  <input type="text" name="bandwidth" id="bandwidth"> 
  <input type="text" name="total" id="total"> 
  <script>
$("#bandwidth").on("keyup", function() {
  this.value = this.value.replace(/[^0-9]/,'');
  var total = this.value*0.18;
  $('#total').val('?'+ total.toFixed(2));
});

      </script>  
 </body>
</html>

Related Tutorials