Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Pages - Customize & Extend
Answered

Datepicker show on input field

(0) ShareShare
ReportReport
Posted on by 18

Hello

 

I have a datepicker on an entity form.  I would like to show the calendar on click or focus of the input field associated with the datepicker.  I need to prevent the manual entry of date into the input field and simply launch the calendar on focus of the input text field that has calendar icon at the end. Is there a way to do this ? 

 

Thank You

Categories:
  • RK89 Profile Picture
    18 on at
    Re: Datepicker show on input field

    Thanks to both of you. It worked. I used the following script.

    $(document).ready(function() {

     

    $("#bill_datepaid_datepicker_description").focus(function() {

     

    $("#bill_datepaid").next().data("DateTimePicker").disable();

    $("#bill_datepaid").next().data("DateTimePicker").enable();

    $("#bill_datepaid").next().data("DateTimePicker").show();

    //$('#bill_datepaid_datepicker_description').attr('readonly', true);

    });

    });

     

    When I had readonly true it worked only on first time focus on the input field. I was not able to launch the calendar on refocussing the input field again. There was no error in the console. Not sure why. Any thoughts ?

     

    Thanks

    R89

  • Verified answer
    Fubar Profile Picture
    7,955 Super User 2025 Season 1 on at
    Re: Datepicker show on input field

    You may need to more than this with regards to locking down the Input field etc but these are the basic calls you would need for showing etc the datepicker

    // disable the date field and picker
    $("#your_fieldname") // input control
     .next() // the date picker container
     .data("DateTimePicker") // the date picker object
     .disable();
    
    // enable the control after disabling
    $("#your_fieldname").next().data("DateTimePicker").enable();
    
    // show the date picker (like someone clicked the icon)
    $("#your_fieldname").next().data("DateTimePicker").show();

     

  • Verified answer
    Christian Leverenz Profile Picture
    1,214 on at
    Re: Datepicker show on input field

    Hi @RK89 ,

    its a while ago i did this kind but it should be possible by registering the click and focus event on the inputcontrol and just raise the clickevent "manually" on the control opening the selector (or call the open method for that one). Please take a look at the dom how the elements are adressable.

    There is one logical problem on that one: if you disable the input (by the js you provide), it may not be able to receive a focusevent any longer (may be, advanced html people can answer this). So, just tabbing over your form might not raise the focusevenet.

    This all requires a little bit javascript. As it is boung to the form, i would recommend to place that js on the form.

    Hope it points in the right direction,

      Christian

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >

Featured topics