Allowing User to select year and month in datepicker

Answered

Comments

9 comments

  • Avatar
    Raju Khadgi

    I am able to fix this

    corrected javascript is 

    $(".a.date").datepicker('option',{

            changeMonth: true,

            changeYear: true,

            yearRange: 'c-20:c+30'

        });

  • Avatar
    Enrico Bisello

    no longer seems to work, only can select months 

  • Avatar
    Raju Khadgi

    Enrico,

    It works, please make sure you added this code under API&Code > Javascript. You have to call it when page renders.

    Here's the full javascript code 

    ------------------------

    $(document).on('knack-page-render.any'

                   , function(event, scene) {

      $(".a.date").datepicker('option',{

            changeMonth: true,

            changeYear: true,

            yearRange: 'c-20:c+30'

        });

    });

    ------------------------

  • Avatar
    Enrico Bisello

    Must be me I guess, or that i can't see it, am using Chrome latest also Tried FF


    Saved after inserting 

    https://beikebiotech.knackhq.com/agetst#home/


  • Avatar
    Raju Khadgi

    Enrico,

    Javascript that I have posted earlier was for a specific control only which has class "a". Do not worry, if you are not familiar with JQuery syntax.

    I just looked into your test page, if you are looking for setting default for all datepicker, you can do as follow.

    Here's the full javascript code 

    ------------------------

    $(document).on('knack-page-render.any'

                   , function(event, scene) {

      $.datepicker.setDefaults({changeMonth: true,changeYear: true, yearRange: 'c-10:c+40'});

    });

    ------------------------


  • Avatar
    Raju Khadgi

    You will see something like below once you change the javascript.


  • Avatar
    Enrico Bisello

    I do see it now and I am Happy can't thank you enough winner !!!

  • Avatar
    Raju Khadgi

    glad it works for you

  • Avatar
    Jon Evans
    Awesome!!! Thanks!  Works perfectly for birth date especially!

Please sign in to leave a comment.