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

Restrict alphabets in dateinput textbox

1 Answer 302 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
sudheer
Top achievements
Rank 2
sudheer asked on 26 Dec 2008, 06:18 AM

Hi

i have a raddatepicker using skin=webblue,  if user enter alphabetical  and special characters it is allowing  but it should not.
could anybody help

Very urgency ...

Thanks in advance

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 26 Dec 2008, 08:17 AM
Hi sudheer,

You can use the DateInput's KeyPress client-side event handler:

ASPX

<telerik:RadDatePicker ID="RadDatePicker1" runat="server"
    <DateInput runat="server" ClientEvents-OnKeyPress="KeyPress" /> 
</telerik:RadDatePicker> 

Javascrript

function KeyPress(sender, args) 
    var re = /^[0-9\-\:\/]$/; 
    args.set_cancel(!re.test(args.get_keyCharacter())); 


The above code will allow numbers, dashes, colons and slashes. You can remove the unnecessary symbols, according to your requirements.





Greetings,
Dimo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Calendar
Asked by
sudheer
Top achievements
Rank 2
Answers by
Dimo
Telerik team
Share this question
or