[thelist] javascript numbers with decimals
Daniel Kessler
danielk at umd.edu
Tue May 6 08:26:45 CDT 2008
I'm trying to ensure that all characters entered into a field are
numbers AND/OR a decimal. Valid entries are similar to: 521,
521.44, .44, 521.4 Invalid entries would be: $521, 52o
I'm working from code that works in another library and I have it
removing all numbers, but it won't allow a decimal. I'd like to
understand what the code is doing and how to also allow a decimal.
Here's the code that I have so far:
regEx = /\D/g; // String to remove any characters that are not numbers
filteredField=field.value.replace(regEx,"") // text field numeric
characters only
Clearly I need to update the first line to include the decimal, but
haven't yet figured out how. I'll keep on it.
Oh, and please cc me with any replies as I get these postings digest.
thank you.
--
Daniel Kessler
University of Maryland College Park
School of Public Health
3302E HHP Building
College Park, MD 20742-2611
Phone: 301-405-2545
http://sph.umd.edu
More information about the thelist
mailing list