<input type="text" onkeypress="price(this.value);" /> <script> function price(n) { alert(n); } </script>