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>
The following code meets the expectation. Thank you for all your replies.
Code: