www.webdeveloper.com
Results 1 to 4 of 4

Thread: How to format textbox amount to .00 when there is no decimal places

  1. #1
    Join Date
    Sep 2009
    Posts
    5

    How to format textbox amount to .00 when there is no decimal places

    Hello All,

    in my form(based on pure java script) i have a MakePrice textbox, it is basically user enters only numeric (money value), but the requirement is it needs to be round to 2 decimals
    i am getting with the help of below function
    document.OrdProcessFrm.MakePrice.value= (Math.round(document.OrdProcessFrm.MakePrice.value*100))/100;
    it is giving what i want , but the thing when user enters just 350 it shows only 350 i want to show 350.00 (.00 when user wont enter decimals)


    so if user enters 342.567 it will becomes 342.57 it is working fine
    if user enters 342 it will be staying as just 342 but i need it to be as 342.22 when last the focus for the textbox

    Please Help me any ideas

    Thanks in advance
    mohini

  2. #2
    Join Date
    Sep 2009
    Posts
    5
    please any one can help me

  3. #3
    Join Date
    Sep 2009
    Posts
    5
    any ideas????? please

  4. #4
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,350

    Arrow

    Quote Originally Posted by mohini7 View Post

    so if user enters 342.567 it will becomes 342.57 it is working fine
    if user enters 342 it will be staying as just 342 but i need it to be as 342.22 when last the focus for the textbox
    Your request does not make sense to me.

    Why would you change the user's entry to 342.22 when THEY entered 342?
    If a site starts changing the values of the entries I make, I'm out of there in a hurry.
    Computers may one day rule the world, but not today.

    Also, if you are displaying numbers as currency string, you could just as easily
    use something like 342.toFixed(2) or (342.2222222).toFixed(2)
    to achive an output of 342.00 or 342.22

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles