Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8885309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:16:43+00:00 2026-06-14T21:16:43+00:00

Currently I am facing an issue in formatting decimals. On the blur event of

  • 0

Currently I am facing an issue in formatting decimals.

On the blur event of the text box, if the user enters:

1) 1    -> this should be converted to 001.00
2) 2.5  -> this should be converted to 002.50
3) .5   -> this should be converted to 000.50
4) 12.4 -> this should be converted to 012.40

All inputs should be converted to the same format upon leaving the input or losing focus.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T21:16:44+00:00Added an answer on June 14, 2026 at 9:16 pm
    <input type="text" onblur="formatDecimal(this)" />
    
    <script type="text/javascript">
        function formatDecimal(input) {
            var val = '' + (+input.value);
            if (val) {
                val = val.split('\.');
                var out = val[0];
                while (out.length < 3) {
                    out = '0' + out;
                }
                if (val[1]) {
                    out = out + '.' + val[1]
                    if (out.length < 6) out = out + '0';
                } else {
                    out = out + '.00';
                }
                input.value = out;
            } else {
                input.value = '000.00';
            }
        }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am facing issue in updating a primefaces dialog box Currently I am displaying
I am currently facing this issue in my application. please help me out. activity
I'm currently facing the following issue: My app dynamically creates images (320 x 480
I'm currently facing this problem with ruby on rails 3, devise and facebook oauth.
I’m currently facing an issue that my Oracle knowledge cannot solve, I’m definitely not
I am working on Wi-Engine and currently facing the issue while loading two sheets
This is the continuation of issue I'm currently working on a task where it
I'm currently facing a (little) blocking issue. I'd like to replace a substring by
I'm working on a user facing django application for an enterprise solution. Currently, users
Currently I am facing an issue with my Makefile caused by evaluation of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.