<!DOCTYPE html> <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script> <meta charset=utf-8 /> <title>JS Bin</title> <script> $(document).ready(function(){ $("#txt").keyup(function(){ var v=$("#txt").val(); var reg=/^1?[1-9]?d([.]d)?$/; var r=reg.test(v); $("#re").text(r); }); }); </script> </head> <body> <input type="text" id="txt" > <span id="re"></span> </body> </html>