Javascript examples for jQuery:Form Number Field
Ensure only valid numeric characters are entered into a textbox
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.4.3.min.js"></script> <script type="text/javascript"> $(function() {//from w w w. j a va2 s . c o m $("input").keyup(function() { this.value = this.value.match(/[-+]?[0-9]*\.?[0-9]*/); }); }); </script> </head> <body> <input type="text"> </body> </html>