Disable manual input and only allow pop-up selection?

5 posts, 0 answers
  1. Michael Malone
    Michael Malone avatar
    68 posts
    Member since:
    May 2010

    Posted 19 Jun 2015 Link to this post

    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. 
  2. Michael Malone
    Michael Malone avatar
    68 posts
    Member since:
    May 2010

    Posted 22 Jun 2015 Link to this post

    Any ideas? Thanks.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 23 Jun 2015 Link to this post

    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
  5. Michael Malone
    Michael Malone avatar
    68 posts
    Member since:
    May 2010

    Posted 23 Jun 2015 in reply to Viktor Tachev Link to this post

     

    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;

  6. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 26 Jun 2015 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017