Restrict alphabets in dateinput textbox

2 posts, 0 answers
  1. sudheer
    sudheer avatar
    109 posts
    Member since:
    Dec 2008

    Posted 26 Dec 2008 Link to this post


    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
  2. Dimo
    Admin
    Dimo avatar
    8457 posts

    Posted 26 Dec 2008 Link to this post

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