RadTextbox validation

3 posts, 0 answers
  1. srinivasskc
    srinivasskc avatar
    12 posts
    Member since:
    Sep 2012

    Posted 29 Aug 2012 Link to this post

    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. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 31 Aug 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 03 Sep 2012 Link to this post

    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.
Back to Top