RadCalendar : Accept only numerals in the editing box

2 posts, 0 answers
  1. Udaya Kumar
    Udaya Kumar avatar
    4 posts
    Member since:
    Aug 2009

    Posted 28 Sep 2009 Link to this post

    Dear Telerik Team,

    I just wonder ,is there any way to make the users to enter only the numeric values in the edit box of the calendar ? currently it accepts the alphabets as well.

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 29 Sep 2009 Link to this post

    Hi Udaya,

    I tried following approach in order to prevent alphabets in input of RadDatePicker.

    ASPX:
     
    <telerik:RadDatePicker ID="datepicker2" runat="server" Culture="English (United States)"
        <DateInput ID="DateInputSentQcDate" DateFormat="MM/dd/yyyy" Style="color: Navy" runat="server"
            <ClientEvents OnKeyPress="OnKeyPress" /> 
        </DateInput> 
    </telerik:RadDatePicker> 

    JavaScript:
     
    <script type="text/javascript"
        function OnKeyPress(sender, eventArgs) { 
            var c = eventArgs.get_keyCode(); 
            if (!((c < 65) || (c > 90 && c < 97) || (c > 122))) 
                eventArgs.set_cancel(true); 
        } 
    </script> 

    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top