Blacklist alphabets.

6 posts, 0 answers
  1. Tia
    Tia avatar
    18 posts
    Member since:
    Mar 2013

    Posted 25 Mar 2013 Link to this post

    Hi,

    I want to know how to prevent the user from entering alphabets in a textbox and show a warning symbol if user attempt to enter alphabets.

    Thanks,
    Tia.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 25 Mar 2013 Link to this post

    Hi,

    One suggestion is that you can use RadNumericTextBox which restricts user input to numeric values. Check the following documentation for more.
    RadNumericTextBox Basics

    Thanks,
    Shinu
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tia
    Tia avatar
    18 posts
    Member since:
    Mar 2013

    Posted 25 Mar 2013 Link to this post

    Hi Shinu, I am aware of the RadNumericTextBox but it allows only numbers. I just want to restrict alphabets only and accept special characters also.
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 26 Mar 2013 Link to this post

    Hi,

    Try the following code.

    ASPX:
    <telerik:RadTextBox ID="RadTextBox1" runat="server">
        <ClientEvents OnKeyPress="OnKeyPress" />
    </telerik:RadTextBox>
    <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/warning.gif" ImageAlign="AbsMiddle"
        Height="16px" Width="16px" Style="margin-left: -22px; margin-top: 3px; display: none;" />

    JavaScript:
    <script type="text/javascript">
        function OnKeyPress(sender, args) {
            var Image1 = document.getElementById('<%=Image1.ClientID%>');
            var text = sender.get_value() + args.get_keyCharacter();
            if (!text.match('^[0-9#$%^&*()@!]*$')) {
                if (args.get_keyCode() != 13) {
                    Image1.style.display = "inline";
                    args.set_cancel(true);
                }
                else {
                    Image1.style.display = "none";
                }
            }
            else {
                Image1.style.display = "none";
            }
        }
    </script>

    Thanks,
    Shinu
  6. Tia
    Tia avatar
    18 posts
    Member since:
    Mar 2013

    Posted 26 Mar 2013 Link to this post

    Thanks shinu for your valuable reply.
  7. Shivam
    Shivam avatar
    5 posts
    Member since:
    Mar 2015

    Posted 21 Mar 2015 in reply to Shinu Link to this post

    I am using a simple RadNumericTextBox.
    But none of the properties are working.


    My requirements:1) Group Separator 2) SelectionOnFocus = "SelectAll"
    I have tried everything for above two but none of the things worked.
    Observtions: 1) maxlength property is working if i use. 2) minvalue property is also working. 3) Decimal value is also working.Can anyone help me out on this. It is very much needed.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017