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

RadTextbox validation

2 Answers 512 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
srinivasskc
Top achievements
Rank 1
srinivasskc asked on 29 Aug 2012, 12:46 PM
In textbox,cant we restrict to type only alphabets - if we give not to enter numbers.

Its been heard that Telerik controls cant work with asp.net ajax validations?

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 31 Aug 2012, 07:43 AM
Hi,

Try the following JavaScript to allow only numbers in RadTextBox.
JS:
function OnKeyPress(sender, args)
{
     var text = sender.get_value() + args.get_keyCharacter();
     if (!text.match('^[a-z]+$'))
     args.set_cancel(true);
}

Thanks,
Shinu.
0
Vasil
Telerik team
answered on 03 Sep 2012, 07:25 AM
Hello srinivas,

On first look the Shinu's solution will work perfectly client side. You will need to validate the values server side also. You can do this by checking the .Text property of RadTextBox manually, or still use asp:Validator for this purpose.

For using asp:validators in combination with RadInput controls see these resources:
http://demos.telerik.com/aspnet-ajax/input/examples/common/validation/defaultcs.aspx
http://www.telerik.com/help/aspnet-ajax/input-validation.html
http://www.telerik.com/help/aspnet-ajax/input-textbox-limiting-allowable-values.html

Regards,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Ajax
Asked by
srinivasskc
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Vasil
Telerik team
Share this question
or