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 7659165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:17:49+00:00 2026-05-31T13:17:49+00:00

I have a simple text box and I am entering number value to this.And

  • 0

I have a simple text box and I am entering number value to this.And i want to format the number value to two decimal places.Like If i enter the 10 in the text box and after pressing entering or leaving textbox it should be converted into 10.00.Please tell me if there exist any possibility to do this using javascript or vb.net or asp.net property of textbox.I already tried in JavaScript on enter key or tab key press but it convert it into 10.00 each time when i press the enter or tab.here is code

//Make Formatting with .00


document.onkeydown = function disableKeys() {

    if( typeof event != 'undefined' ) {
      if( (event.keyCode == 9) ||
          (event.keyCode == 13) ) {
          var a;
          var b;
          a=parseFloat(document.getElementById('txtpkrusd').value,10);
          b=parseFloat(document.getElementById('txtRatelb').value,10);
          document.getElementById('txtpkrusd').value=formatNumber(a);         
          document.getElementById('txtRatelb').value=formatNumber(b);         

      }
    };
};
  • 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-05-31T13:17:50+00:00Added an answer on May 31, 2026 at 1:17 pm

    hiya hope this helps: (apart from my comment above i.e. to round use .toFixed(num))

    demo (enter the number and press enter) : http://jsfiddle.net/6wG26/5/ OR Enter and Tab keys both here http://jsfiddle.net/Mtw7c/7/

    Please; let me if this is not what you want I will delete my post; but this will help you.

    Since you dint had much code up I have made forked sample here:

    **HTML:**
    
    <input type="text" name="one" class="currency">
    
    
    **JQuery code:**
    
        (function($) {
            $.fn.currencyFormat = function() {
                this.each( function( i ) {
                    $(this).change( function( e ){
                        if( isNaN( parseFloat( this.value ) ) ) return;
                        this.value = parseFloat(this.value).toFixed(2);
                    });
                });
                return this; //for chaining
            }
        })( jQuery );
    
    
        $( function() {
            $('.currency').currencyFormat();
        });​
    

    OR ENter key & Tab key here: http://jsfiddle.net/Mtw7c/7/

     $('.currency').live('keydown', function(e) { 
            var key = e.keyCode || e.which; 
    
              if (key== 9 || key == 13) { 
                e.preventDefault(); 
                  if( isNaN( parseFloat( this.value ) ) ) return;
                        this.value = parseFloat(this.value).toFixed(2);
                // call custom function here
              }         
    
        });
    

    ​

    hope this helps and it will be good if you read the following link – sample taken from here but to make it sample for you, In jQuery, what's the best way of formatting a number to 2 decimal places?

    You can always put validation for the number only text box & other amendments, Hope this helps mate, cheers!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple dojo text box and a value picker. I want to
I have this html page which is very simple, it contains a text box
I have a simple text box in a WPF application. I need to know
I have a simple page. One Rich Text Box bound to a test table
I have a simple form using a POST method, consisting of a text box
I have a simple form with one text box and a panel with three
I have a simple text field on my page, with the initial text value
I would like a simple text box input of a date in the past
I have a simple form with one text box that pass data to SQL
I have a simple ASP.Net MVC View which contains an FCKeditor text box (created

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.