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

Disable manual input and only allow pop-up selection?

4 Answers 70 Views
TimePicker
This is a migrated thread and some comments may be shown as answers.
Michael Malone
Top achievements
Rank 1
Michael Malone asked on 19 Jun 2015, 01:05 PM
How can I disable the user from manually entering values with the keyboard? Selections should only come from the pop-up values. I tried setting the DateInput.ReadOnly to True but that disabled the popup as well. 

4 Answers, 1 is accepted

Sort by
0
Michael Malone
Top achievements
Rank 1
answered on 22 Jun 2015, 12:29 PM
Any ideas? Thanks.
0
Viktor Tachev
Telerik team
answered on 23 Jun 2015, 12:25 PM
Hello Michael,

Setting the ReadOnly property of the DateInput should not disable the popup. If the popup is not opening it could be due to a JavaScript error. Would you open the browser console and see if there are any errors listed?

With this said, the following code should not allow the user to enter custom text in the DateInput of a RadTimePicker control.


<telerik:RadTimePicker runat="server" ID="RadTimePicker1">
    <DateInput ReadOnly="true"></DateInput>
</telerik:RadTimePicker>




Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Michael Malone
Top achievements
Rank 1
answered on 23 Jun 2015, 02:18 PM

 

If I set DateInput.ReadOnly = true then I can only get the popup  to work if the TimePopupButton.Visible property is set to true. If I set it to false, the ShowPopupOnFocus stops working. I need the TimePopupButton hidden and ShowPopupOnFocus to still render the popup.

 

this.ShowPopupOnFocus = true;
this.TimePopupButton.Visible = false;
this.Width = Unit.Pixel(55);
this.DateInput.ReadOnly = true;

0
Viktor Tachev
Telerik team
answered on 26 Jun 2015, 11:40 AM
Hello Michael,

When ShowPopupOnFocus is set to true the popup is shown when the DateInput is focused. However, if it is ReadOnly the user cannot enter values in the input and cannot also focus it.

In order to implement the behavior you are looking for you can use the following approach:

Markup:

<telerik:RadTimePicker runat="server" ID="RadTimePicker1" TimePopupButton-Visible="false" ShowPopupOnFocus="true" >
    <DateInput ClientEvents-OnKeyPress="keyPress" ></DateInput>
</telerik:RadTimePicker>


JavaScript:


function keyPress(sender, args) {
    args.set_cancel(true);
}


With this setup the user will still not be able to enter custom values in the DateInput.


Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
TimePicker
Asked by
Michael Malone
Top achievements
Rank 1
Answers by
Michael Malone
Top achievements
Rank 1
Viktor Tachev
Telerik team
Share this question
or