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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:17:16+00:00 2026-05-27T10:17:16+00:00

I have a radtextbox with double type mode. And i have set round as

  • 0

I have a radtextbox with double type mode. And i have set round as 1. So it is giving the result as

 20.6 => 20.5
 20.7 => 20.5
 20.9 => 21.0

But all i need is like this (few samples)

 20.6 => 21.0
 20.5 => 20.5
 20.4 => 20.0

 20.29 => 20.0
 20.53 => 20.5
 20.59 => 21

I tried to fix this by restricting the more than one decimal value. but the code is not working properly.

Code:

<script type="text/javascript">
function GetIndex(sender, args) {
    var textbox = $find('<%= CPDPointsTextBox.ClientID %>');
    var val = textbox.get_value();
    var dsds = val.toString();        
    if (dsds.indexOf(".") > -1) {
        if (dsds.length - (dsds.indexOf(".") + 1) > 1) {
            alert(dsds.length - (dsds.indexOf(".") + 1));
            args.set_cancel(true);               
        }
        else
            return true;
    }
    else {
        if (parseInt(dsds) > 0) {
            return true;
        }
        else
            args.set_cancel(true);
    }
}

<telerik:RadNumericTextBox ID="CPDPointsTextBox" Width="39px" runat="server" MaxLength="5"
                                            MaxValue="999" MinValue="0">
                                            <NumberFormat DecimalDigits="1" KeepNotRoundedValue="false" />
                                            <ClientEvents OnValueChanged="CPDPointsTextBox_ValueChanged" OnKeyPress="GetIndex" />
                                        </telerik:RadNumericTextBox>
  • 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-27T10:17:16+00:00Added an answer on May 27, 2026 at 10:17 am

    The following code meets the expectation. Thank you for all your replies.

    Code:

        function change(lnk, evt) {
        var textbox = $find('<%= CPDTextBox.ClientID %>');
        var val = lnk.value.toString();
        if (val != '') {
            if (val.indexOf(".") > -1) {
                var values = new Array();
                values = val.split(".");
                var rouDec = round(parseFloat('.' + values[1]), 1);
    
                if (rouDec > .5) {
                    val = parseInt(values[0]) + 1;
                }
                else if (rouDec == .5) {
                    val = parseInt(values[0]) + .5;
                }
            }
        }
    
        textbox.set_value(val);
    }
    
    function round(n, dec) {
        n = parseFloat(n);
        if (!isNaN(n)) {
            if (!dec) var dec = 0;
            var factor = Math.pow(10, dec);
            return Math.floor(n * factor + ((n * factor * 10) % 10 >= 5 ? 1 : 0)) / factor;
        } else {
            return n;
        }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have converted devise new session from erb to Haml but doens't work, this is
Have searched the database but need to specifically sum(of hours flown or days off)in
Have seen that this piece of code could solve my problems but I don't
Have seen multiple posts on this but I can't see any which answer my
Have you managed to get Aptana Studio debugging to work? I tried following this,
I have some code where I need two separate required field validators for one
have anyone can tell me what syntax error on this actionscript (actionscript3.0)? var rotY:
Have a rather abstract question for you all. I'm looking at getting involved in
Have a look at this url: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:jquery_ui_methods#column_chooser I have got the Column Chooser dialog
have Googled the cr*p out of this one so apologies if the answer is

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.