Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: Formatting numbers to currency


Message #1 by Mark Eckeard <meckeard2000@y...> on Thu, 25 Apr 2002 21:30:11 -0700 (PDT)
I was able to get this working.

Thanks guys.
--- Gustavo Demaria <gmdemaria@t...> wrote:
> First You may be want to check that the input entry
> is a number
> then , I generally put isnumber() function in onblur
> event of input element
> then you can take de input's value and convert tu
> decimal precision that you
> need with tofixed
> 
> <INPUT id=number1 name=number1 onblur=isnumber() >
> 
> function isnumber() {
>   var oinput;
>  var aux=0;
>   oinput
> document.getElementById(event.srcElement.id);
> 
>    if (isNaN(oinput.value)) {
>    oinput.value = ""
>    oinput.focus();
>    alert("Must entry number values");
>    }
>   else {
>     aux= oinput.value
>     oinput.value= aux.toFixed(2);
>  }
>  }
> 
> I Expects this help.
> ----- Original Message -----
> From: "Mark Eckeard" <meckeard2000@y...>
> To: "JavaScript HowTo"
> <javascript_howto@p...>
> Sent: Friday, April 26, 2002 1:30 AM
> Subject: [javascript_howto] Formatting numbers to
> currency
> 
> 
> > Hi,
> >
> > I have some text boxes that I assign some amounts
> to.
> > I need to format the numbers, like in US currency:
> >
> > 15 = 15.00
> > 43.3 = 43.30
> >
> > How can I do this?
> >
> > Thanks,
> > Mark
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Yahoo! Games - play chess, backgammon, pool and
> more
> > http://games.yahoo.com/
> >
> >
> > ---
> >
> > Improve your web design skills with these new
> books from Glasshaus.
> >
> > Usable Web Menus
> >
>
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
> > r-20
> > Constructing Accessible Web Sites
> >
>
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
> > r-20
> > Practical JavaScript for the Usable Web
> >
>
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
> > r-20
> >
> 
> 
> 
> ---
> 
> Improve your web design skills with these new books
> from Glasshaus.
> 
> Usable Web Menus
>
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
> r-20
> Constructing Accessible Web Sites
>
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
> r-20
> Practical JavaScript for the Usable Web
>
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
> r-20


__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com

  Return to Index