[Javascript] Regular Exp

Laurent Muchacho LaurentM at london.virgin.net
Fri Jan 7 08:29:05 CST 2005


hi Hakan,

yes you right it match anything but number. Thanks this do put me in the
right direction but it seems a bit more complicated then I expected because
I'm checking the value on each onKeyUp event. It mean that when you start
typing eg: 1 for 100.55 it return false until you got the whole number.

Thanks for getting back so quick and for the help provided.

Regards

Laurent

-----Original Message-----
From: Hakan M (Backbase) [mailto:hakan at backbase.com]
Sent: 07 January 2005 12:26
To: [JavaScript List]
Subject: Re: [Javascript] Regular Exp


 > var number_re = /[^0-9]/g

This regexp rather matches anything BUT a number, unless I'm completely 
confused.

You could try this, it's untested but should be in the right direction.

var number_re = /[0-9]+\.[0-9]{2}/;

Regards,
H

Laurent Muchacho wrote:
> Hi Guru's
> 
> I got a regex I need but can't find any good references on regex since
> netscape brought down devedge.
> 
> What I need is a regex that match any number with 2 decimal 100.00 or
43.54
> I call a function on the event onKeyDown on my input type text and check
if
> you input a number.
> I got the logic working fine but my regex only match number and I need a
> number with 2 decimal. 
> 
> this is what I got for matching only number.
> var number_re = /[^0-9]/g
> 
> I tried this to match any number and a dot but it doesn't work.
> var number_re = /[^0-9]+\./g
> 
> I hope you guy's can give me a hand on this and with shawn relaunching
this
> list a few days ago I'm desperate about this regex skills he was talking
> about.
> 
> Thanks 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
> 
> 
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript



More information about the Javascript mailing list