[thelist] javascript numbers with decimals
Scott Brady
dsbrady at gmail.com
Tue May 6 09:17:24 CDT 2008
On Tue, May 6, 2008 at 7:26 AM, Daniel Kessler <danielk at umd.edu> wrote:
> 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
Is there a reason you can't just use the isNaN() function to verify
that it's numeric?
Scott
--
-----------------------------------------
Scott Brady
http://www.scottbrady.net/
More information about the thelist
mailing list