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

RadCalendar : Accept only numerals in the editing box

1 Answer 36 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Udaya Kumar
Top achievements
Rank 2
Udaya Kumar asked on 28 Sep 2009, 01:03 PM
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.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 29 Sep 2009, 05:52 AM
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.
Tags
Calendar
Asked by
Udaya Kumar
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Share this question
or