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

RadNumeric -ASP

10 Answers 240 Views
Input
This is a migrated thread and some comments may be shown as answers.
Eva
Top achievements
Rank 1
Eva asked on 08 Jan 2009, 08:47 PM
Hi All,

I need a RadNumeric TextBox ,which will accept only full number like 0,1,2....  .It won't accept negative number , decimal point ..
How do i customize this behavior.

Also i want to apply validation similar to RadDateInput ,shown in this demo
http://demos.telerik.com/aspnet-ajax/Input/Examples/RadDateInput/FirstLook/DefaultCS.aspx

Can anybody help me ASP.

Thanks in Advance.
Eva

10 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 09 Jan 2009, 11:42 AM
Hi Eva,

Try setting the DecimalDigits attribute of the RadNumericTextBox to zero  for preventing the decimal point. For preventing negative value set MinValue to zero.

ASPX:
telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server" MinValue="0" Type="Number" > 
          <NumberFormat  DecimalDigits="0"/> 
        </telerik:RadNumericTextBox> 

You can also refer the following demo link for getting details on setting Validation with RadNumericTextBox.
Validation

Shinu

0
Eva
Top achievements
Rank 1
answered on 09 Jan 2009, 06:18 PM
Hi Shinu,

Thanks for your reply.

I tried your code, it's still accepting decimal values,like 23.6777.  I don't want user to enter decimal points,is there any way to do that.

I want to show the validation for RadNumericTextBox similar to  RadDateInput  . Like allow the user to enter any information ,but while leaving it should pop up with red color error icon ,with the user information. Is it clear.

I would like to explain in visualy but unfortunately there is no option to upload in this forums.

Please let me know ASP.

Thanks in advance.
Eva
0
Princy
Top achievements
Rank 2
answered on 13 Jan 2009, 09:39 AM
Hi Eva,

If you need to prevent user from entering the decimal point in the numeric textbox you can try the following approach.

ASPX:
 <ClientEvents  OnBlur="Blur" OnKeyPress="KeyPress" /> 


JS:
<script type="text/javascript" language="javascript"
 
function KeyPress(sender, eventArgs) 
 var c = eventArgs; 
 if (c.get_keyCharacter()=='.'
  { 
   
      eventArgs.set_cancel(true); 
   } 
 
</script> 


Princy
0
Eva
Top achievements
Rank 1
answered on 14 Jan 2009, 11:55 PM

Is there any workaround to show the validation for RadNumericTextBox similar to  RadDateInput  . Like allow the user to enter any information ,but while leaving it should pop up with red color error icon inside textbox ,with the user information.
Is it clear.

0
Steve Y
Top achievements
Rank 2
answered on 15 Jan 2009, 05:57 AM
Check out RadInputManager to see if it'll work for you.

You can find the demos here. http://demos.telerik.com/aspnet-ajax/Input/Examples/RadInputManager/FirstLook/DefaultCS.aspx

Regards, Steve
0
Eva
Top achievements
Rank 1
answered on 15 Jan 2009, 06:04 PM
I tried this demo.But it doesn't work.

My question is i need to act RadNumeric Textbox validation simillar to raddateinput validation (like user can enter any information ,but while leaving it should pop up with red color error icon inside textbox ,with the user information)

Is it possible.

Thanks in Advance.
Eva
0
Steve Y
Top achievements
Rank 2
answered on 15 Jan 2009, 06:35 PM
Yep - you're right. It doesn't act the way you want.

It stops you from entering anything other than numeric data plus formatting (.,-etc). If you enter a number higher than max, it will substitute max, and if you put in anything lower than min, it'll substitute min.

I think I would prefer it to display an error message and allow the user to go and fix it vs. change the data input and hope it's what the user wants. This would then give it a level of consistency with the way regex, masked and required validation works.

Anyone else have any thoughts on this? Telerik?

Thanks, Steve
0
Eva
Top achievements
Rank 1
answered on 15 Jan 2009, 07:17 PM


Thanks steve , you are correct , even i am looking for simillar bevaviour. 
It will be good user can see what they are entering simillar to raddateinput validation.

Telerik ?




0
Dimo
Telerik team
answered on 16 Jan 2009, 07:43 AM
Hello Eva,

We will implement the requested behavior in a future version of the control. Thanks for the suggestion.

In the meantime, you can use something like this:


<%@ Page Language="C#" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<script runat="server"
 
    public double NumericMinValue; 
    public double NumericMaxValue; 
     
    protected void Page_Load(object sender, EventArgs e) 
    { 
        NumericMinValue = RadNumericTextBox1.MinValue; 
        NumericMaxValue = RadNumericTextBox1.MaxValue; 
 
        RadNumericTextBox1.MinValue = Double.MinValue; 
        RadNumericTextBox1.MaxValue = Double.MaxValue; 
    } 
     
</script> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
<title>RadControls for ASP.NET AJAX</title> 
</head> 
<body> 
<form id="form1" runat="server"
<asp:ScriptManager ID="ScriptManager1" runat="server" /> 
 
<p> 
NumericMinValue: <%= NumericMinValue %> 
<br /> 
NumericMaxValue: <%= NumericMaxValue %> 
</p> 
 
<p>Enter an invalid value:</p> 
 
<telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server" MinValue="10" MaxValue="20"
    <ClientEvents OnValueChanged="ValueChanged" /> 
</telerik:RadNumericTextBox> 
 
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"
<script type="text/javascript"
 
var numericMinValue = <%= NumericMinValue %>
var numericMaxValue = <%= NumericMaxValue %>
 
function ValueChanged(sender, args) 
    if (args.get_newValue() < numericMinValue || args.get_newValue() > numericMaxValue) 
    { 
        sender._invalid = true
    } 
    else 
    { 
        sender._invalid = false
    } 
     
    sender.updateCssClass(); 
 
</script> 
</telerik:RadCodeBlock>  
 
</form> 
</body> 
</html> 
 


Sincerely yours,
Dimo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Dimo
Telerik team
answered on 03 Jul 2009, 05:32 PM
Hello,

I would like to inform you that we have just implemented the requested functionality, namely - if you enter a number, which is beyond the range of valid values, RadNumericTextBox will keep showing the value together with its InvalidStyle (the control will have no value). The behavior of the textbox will be controlled via a property and the default behavior will be the same as until present.

The feature will be included in the next service pack and nightly builds.

All the best,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Input
Asked by
Eva
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Eva
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Steve Y
Top achievements
Rank 2
Dimo
Telerik team
Share this question
or