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

RadDatepicker

1 Answer 95 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Atchut
Top achievements
Rank 1
Atchut asked on 31 May 2012, 11:27 PM
Hello,

I am using this control for the first time. I have couple of questions.
1) RadDatepicker textbox is allowing alphabets and special characters to enter. Is thery anyway that we can restrict not to enter alphabets and special characters
2) How to Enable dates from today only ? I dont want to user to select dates back from today.

TIA

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 01 Jun 2012, 05:54 AM
Hi Atchut,

1) You can use the DateInput's KeyPress client-side event handler to restrict alphabets and special characters to enter into the DateInput.The below code will allow numbers, dashes, colons and slashes. You can remove the unnecessary symbols, according to your requirements.

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

JS:
<script type="text/javascript">
  function OnKeyPress(sender, args)
    {
        var re = /^[0-9\-\:\/]$/;
        args.set_cancel(!re.test(args.get_keyCharacter()));
    }
</script>

2) Set the MinDate of the RadDatePicker control to disable the past days.

C#:
protected void Page_Load(object sender, EventArgs e)
    {
        RadDatePicker1.MinDate = DateTime.Today.Date;
    }

Hope this helps.

Regards,
Princy.
Tags
Grid
Asked by
Atchut
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or