[thelist] javascript numbers with decimals

Hassan Schroeder hassan.schroeder at gmail.com
Tue May 6 08:51:40 CDT 2008

On Tue, May 6, 2008 at 6: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

  regEx = /[^\d\.]/g; // what's not (^) a decimal (\d) or literal . (\.)

Hassan Schroeder ------------------------ hassan.schroeder at gmail.com

More information about the thelist mailing list