Javascript examples for RegExp:Match Number
Validating numeric value in text field using regex
<html> <head></head> <body> <script> var re = /^\d*\.?\d$/;/*from w w w . j a v a 2s . com*/ var tests = [ 123, 1, 12345, 233.2, 1212.2, 1.1, 1.222, 1.33, -89789, -3 ]; tests.forEach(function(test, i){ document.write(i, '. ', re.test(test), '<br/>'); }); </script> </body> </html>