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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:31:25+00:00 2026-05-26T07:31:25+00:00

i am using asp.net4.0 in this aspx page one text box enter the rate,

  • 0

i am using asp.net4.0 in this aspx page one text box enter the rate, the user enter only numbers(22) it can display 22.00 like that suppose user enter 22.5 it display 22.50 pls help me how to write the code in client side javascript i am writing like this

function Rate(evt) {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
             return false;

         return true;
     }

it taking only numbers, how to write the code in dot also

  • 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-26T07:31:26+00:00Added an answer on May 26, 2026 at 7:31 am

    Try this code:

    function isNumberWithDecimal(evt, source){
        evt =(evt)?evt :window.event;
        var charCode =(evt.which)?evt.which :evt.keyCode;
        var amt = source.value;
        var len = parseInt(amt.length);
        var ind = parseInt(amt.indexOf('.'));
        var cursorPosition = GetCursorLocation(source); 
    
        if(isNaN(amt)){
            evt.keyCode = 0;
            source.value = ".00";
        }
        if(charCode == 46){
            if(ind>-1)
                    evt.keyCode = 0;
        }
        else if(charCode < 48 || charCode >57)
            evt.keyCode = 0;
        else{
            /* it will allow to enter only two digit after decimal point in numeric field      */
            if((len - ind)>2 && ind > -1 && cursorPosition > ind)
                    evt.keyCode = 0;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code like this on some aspx page in my Web Application: <asp:Content
I am using asp.net4 and have CSS presented like this in the head tag.
Solved using this post: Can you convert an ASP.NET MVC Application to a Web
Using VS2008 and ASP.NET 3.5 (or VS 2010 / .NET 4.0?), how can I
Using ASP.net 2.0, how do I present the information to the user similar to
Using ASP.net, how do you write ANSI characters to a text file? I need
Using asp.net MVC I'd like to do this inside a view: <%= Html.TextBox(textbox1, null,
Using ASP MVC and Entity Framework. In the view, you have a page declaration
Using ASP.NET 3.5 and jQuery UI. When a user clicks the Search button, a
I used the ASP.NET (.NET4) default ASPNETDB.mdf database that gets created when using membership,

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.