[thelist] javascript numbers with decimals
Phil Turmel
pturmel-webdev at turmel.org
Tue May 6 09:25:26 CDT 2008
Daniel Kessler wrote:
>
> On May 6, 2008, at 9:50 AM, Phil Turmel wrote:
>> Daniel Kessler wrote:
>>> 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.
>> Try:
>>
>> regEx = /[^0-9\.]/g;
>
> That worked great. I don't quite understand what I'm doing though.
> These chars aren't a string? so they don't have to be quoted?
>
They don't have to be quoted in javascript, as 'regex' is a natively
parsed constant literal[1]. The forward slash delimits the regex.
The reference[1] also includes a nice summary of regular expressions
in general, with examples.
[snip /]
> I very much appreciate the help too.
>
You're welcome.
Regards,
Phil
[1]
http://devedge-temp.mozilla.org/library/manuals/2000/javascript/1.5/guide/regexp.html
--
Need to contact me offlist?
Drop -webdev or you probably won't get through.
More information about the thelist
mailing list