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

Blacklist alphabets.

5 Answers 84 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tia
Top achievements
Rank 1
Tia asked on 25 Mar 2013, 08:39 AM
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.

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Mar 2013, 09:00 AM
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
0
Tia
Top achievements
Rank 1
answered on 25 Mar 2013, 04:51 PM
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.
0
Shinu
Top achievements
Rank 2
answered on 26 Mar 2013, 05:46 AM
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
0
Tia
Top achievements
Rank 1
answered on 26 Mar 2013, 08:16 AM
Thanks shinu for your valuable reply.
0
Shivam
Top achievements
Rank 1
answered on 21 Mar 2015, 07:18 PM
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.
Tags
General Discussions
Asked by
Tia
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Tia
Top achievements
Rank 1
Shivam
Top achievements
Rank 1
Share this question
or