This is a migrated thread and some comments may be shown as answers.

RadNumericTextBox Allowing Decimals

1 Answer 186 Views
Input
This is a migrated thread and some comments may be shown as answers.
Brian Mains CompInc
Top achievements
Rank 1
Brian Mains CompInc asked on 20 Mar 2009, 08:34 PM
Hello,

I'm trying to prevent numbers like:

500.10

I want only amounts like:

500

entered.

I setup the RadNumericTextbox with:

DecimalDigits="0"
DataType="System.Int32"
MinValue="0"

And even though I have this, it still allows 500.10.  Also, ValueChanged seems to fire after the RadNumericTextBox adjusts the value to 500.  So User enters 500.10, the ValueChanged client-side event fires, and the value is adjusted to 500 in RadNumericTextBox.

Is there a way to get the value to adjust before this event fires, or is there a better event to tap into?

Thanks.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Mar 2009, 07:26 AM
Hello Brian,

One suggestion is preventing the user from entering decimal values. I tried to get the Key pressed and cancel the event if tried to enter the decimal.

ASPX:
<telerik:radnumerictextbox id="RadNumericTextBox1" ToolTip="Decimals not allowed" MinValue="0" runat="server" DataType="System.Int32">          
    <NumberFormat DecimalDigits="0" /> 
    <ClientEvents OnValueChanged="OnValueChanged" OnKeyPress="OnKeyPress" /> 
</telerik:radnumerictextbox> 

JavaScript:
<script type="text/javascript">  
function OnValueChanged()  
{  
    alert('Value Changed');  
}  
function OnKeyPress(sender, eventArgs)  
{  
   var c = eventArgs.get_keyCode();  
   if (c ==46) // Typed .  
   {  
     eventArgs.set_cancel(true);   
   }  
}  
</script> 

Thanks,
Princy.
Tags
Input
Asked by
Brian Mains CompInc
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or