Validating javascript decimal numbers
Posted
by Click Upvote
on Stack Overflow
See other posts from Stack Overflow
or by Click Upvote
Published on 2010-03-22T20:16:55Z
Indexed on
2010/03/22
20:21 UTC
Read the original article
Hit count: 309
I'm using the following regexp to validate numbers in my javascript file:
var valid = (val.match(/^\d+$/));
It works fine for whole numbers like 100, 200, etc, however for things like 1.44, 4.11, etc, it returns false. How can I change it so numbers with a decimal are also accepted?
© Stack Overflow or respective owner