How to validate a numeric numbers?
A:
var number_string = document.getElementById("my_input").value;
is_valid = /^[0-9]+$/.test(number_string);
Don't forget to server-side validate as well!
MiffTheFox
2010-04-18 02:51:47
Just for the record, if you want to allow commas or dollar signs just add them after the 9 in the brackets.
Michael Shnitzer
2010-04-18 02:54:19
+1
A:
Look here - this has the answer
http://stackoverflow.com/questions/1303646/check-variable-whether-is-number-or-string-in-javascript
Romain Hippeau
2010-04-18 02:54:03