Javascript examples for jQuery:Form Number Field
Limit number in input text field and do calculation
<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>