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

Mask for alphaNumeric and variable mask length?

1 Answer 216 Views
Input
This is a migrated thread and some comments may be shown as answers.
Delicious!
Top achievements
Rank 1
Delicious! asked on 22 Oct 2009, 10:03 PM
Is there a way for me to set the mask that will allow only numbers and letters (of any case)?  I looked at the documentation and can only see a way to set the mask to be either a number or a letter.  There is the mask a, but that allows users to enter symbols.

Also, is there a way for me to define a mask where I don't know the length of text the user will be entering?  For example, if I have a field for lastName I won't know the length of the name, but I'd like to restrict this field to letters only. 

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 23 Oct 2009, 06:37 AM
Hi Ohrange,

Try adding following event handler to OnKeyPress of RadTextBox in order to get the required functionality.

aspx:
 
<telerik:RadTextBox ID="RadTextBox2" runat="server"
    <ClientEvents OnKeyPress="OnKeyPress" /> 
</telerik:RadTextBox> 

JavaScript:
 
<script type="text/javascript"
    function OnKeyPress(sender, args) { 
        var keyCode = args.get_keyCode(); 
        if (!((keyCode > 47 && keyCode < 58) || (keyCode > 64 && keyCode < 91) || (keyCode > 96 && keyCode < 123))) { 
            args.set_cancel(true); 
        } 
    } 
</script> 

Cheers,
Shinu.
Tags
Input
Asked by
Delicious!
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or