Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] Number validation with digit grouping


  • From: javascript@xxxxxxxxxx (Dan Costea)
  • Subject: [Javascript] Number validation with digit grouping
  • Date: Mon, 21 Oct 2002 13:48:12 +0200

I wrote a function for you:

   function floatTest (sNr)
   {
    var reFloatF1 = /^((\d+(\.\d*)?)|((\d*\.)?\d+))$/; // format 1
    var reFloatF2 = /^((\d+(\,\d*)?)|((\d*\,)?\d+))$/; // format 2

    return (reFloatF1.test (sNr) || reFloatF2.test (sNr));
   }

This should solve your problem.

Dan.

----- Original Message ----- 
From: "Tobias Barlind" <tobias.barlind@xxxxxxxxxxxxx>
To: <javascript@xxxxxxxxxx>
Sent: Monday, October 21, 2002 12:26 PM
Subject: [Javascript] Number validation with digit grouping


> Does anyone have a good snippet that validates a string of numbers that
> has digit grouping?
> 
> I.e "12,200.50"
> 
> isNaN returns true on this.
> 
> And I can't just simply remove all "," because I have to deal with
> different languages having different decimal signs like "," instead of
> "." :)
> 
> //B
> 
> _______________________________________________
> Javascript mailing list
> Javascript@xxxxxxxxxx
> https://lists.LaTech.edu/mailman/listinfo/javascript