dynamically disabling days in pikaday datepicker












0















I'm trying to dynamically change which dates of the month are allowed in a pikaday datepicker based on changes to a username field. i.e. use something like the below to disable all but the 1st of each month. the selector is however not working. i've tried a number of variations. any ideas?



$("#username").on('change', function() { 
if(.........){
$('.pika-button :not([value="1"])').prop("disabled", true);
}
});


here's the inner html of one of these, if it helps:



<button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="11" data-pika-day="1">1</button>


thanks in advance










share|improve this question



























    0















    I'm trying to dynamically change which dates of the month are allowed in a pikaday datepicker based on changes to a username field. i.e. use something like the below to disable all but the 1st of each month. the selector is however not working. i've tried a number of variations. any ideas?



    $("#username").on('change', function() { 
    if(.........){
    $('.pika-button :not([value="1"])').prop("disabled", true);
    }
    });


    here's the inner html of one of these, if it helps:



    <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="11" data-pika-day="1">1</button>


    thanks in advance










    share|improve this question

























      0












      0








      0








      I'm trying to dynamically change which dates of the month are allowed in a pikaday datepicker based on changes to a username field. i.e. use something like the below to disable all but the 1st of each month. the selector is however not working. i've tried a number of variations. any ideas?



      $("#username").on('change', function() { 
      if(.........){
      $('.pika-button :not([value="1"])').prop("disabled", true);
      }
      });


      here's the inner html of one of these, if it helps:



      <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="11" data-pika-day="1">1</button>


      thanks in advance










      share|improve this question














      I'm trying to dynamically change which dates of the month are allowed in a pikaday datepicker based on changes to a username field. i.e. use something like the below to disable all but the 1st of each month. the selector is however not working. i've tried a number of variations. any ideas?



      $("#username").on('change', function() { 
      if(.........){
      $('.pika-button :not([value="1"])').prop("disabled", true);
      }
      });


      here's the inner html of one of these, if it helps:



      <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="11" data-pika-day="1">1</button>


      thanks in advance







      jquery css-selectors jquery-selectors pikaday






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 25 '18 at 9:21









      Bobert1234Bobert1234

      569




      569
























          1 Answer
          1






          active

          oldest

          votes


















          0

















          $(function() {

          $("#username").on('change', '.buttonWrapper', function() {
          $('.pika-button:not([data-pika-day=1])').prop('disabled', true);
          });

          });

          <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

          <body>
          <div class="buttonWrapper">
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="1" data-pika-day="1">Month=1, Day=1</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="5" data-pika-day="1">Month=5, Day=5</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="2" data-pika-day="2">Month=2, Day=2</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="3" data-pika-day="4">Month=3, Day=4</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="4" data-pika-day="4">Month=4, Day=4</button>
          </div>
          <input type="text" id="username" />
          </body>








          share|improve this answer


























          • didn't work. also, i don't really want to remove the options, since i would like them to be re-enabled if the username changes to something that doesn't fall under the condition

            – Bobert1234
            Nov 25 '18 at 10:29













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53466150%2fdynamically-disabling-days-in-pikaday-datepicker%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0

















          $(function() {

          $("#username").on('change', '.buttonWrapper', function() {
          $('.pika-button:not([data-pika-day=1])').prop('disabled', true);
          });

          });

          <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

          <body>
          <div class="buttonWrapper">
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="1" data-pika-day="1">Month=1, Day=1</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="5" data-pika-day="1">Month=5, Day=5</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="2" data-pika-day="2">Month=2, Day=2</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="3" data-pika-day="4">Month=3, Day=4</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="4" data-pika-day="4">Month=4, Day=4</button>
          </div>
          <input type="text" id="username" />
          </body>








          share|improve this answer


























          • didn't work. also, i don't really want to remove the options, since i would like them to be re-enabled if the username changes to something that doesn't fall under the condition

            – Bobert1234
            Nov 25 '18 at 10:29


















          0

















          $(function() {

          $("#username").on('change', '.buttonWrapper', function() {
          $('.pika-button:not([data-pika-day=1])').prop('disabled', true);
          });

          });

          <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

          <body>
          <div class="buttonWrapper">
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="1" data-pika-day="1">Month=1, Day=1</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="5" data-pika-day="1">Month=5, Day=5</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="2" data-pika-day="2">Month=2, Day=2</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="3" data-pika-day="4">Month=3, Day=4</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="4" data-pika-day="4">Month=4, Day=4</button>
          </div>
          <input type="text" id="username" />
          </body>








          share|improve this answer


























          • didn't work. also, i don't really want to remove the options, since i would like them to be re-enabled if the username changes to something that doesn't fall under the condition

            – Bobert1234
            Nov 25 '18 at 10:29
















          0












          0








          0










          $(function() {

          $("#username").on('change', '.buttonWrapper', function() {
          $('.pika-button:not([data-pika-day=1])').prop('disabled', true);
          });

          });

          <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

          <body>
          <div class="buttonWrapper">
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="1" data-pika-day="1">Month=1, Day=1</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="5" data-pika-day="1">Month=5, Day=5</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="2" data-pika-day="2">Month=2, Day=2</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="3" data-pika-day="4">Month=3, Day=4</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="4" data-pika-day="4">Month=4, Day=4</button>
          </div>
          <input type="text" id="username" />
          </body>








          share|improve this answer


















          $(function() {

          $("#username").on('change', '.buttonWrapper', function() {
          $('.pika-button:not([data-pika-day=1])').prop('disabled', true);
          });

          });

          <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

          <body>
          <div class="buttonWrapper">
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="1" data-pika-day="1">Month=1, Day=1</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="5" data-pika-day="1">Month=5, Day=5</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="2" data-pika-day="2">Month=2, Day=2</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="3" data-pika-day="4">Month=3, Day=4</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="4" data-pika-day="4">Month=4, Day=4</button>
          </div>
          <input type="text" id="username" />
          </body>








          $(function() {

          $("#username").on('change', '.buttonWrapper', function() {
          $('.pika-button:not([data-pika-day=1])').prop('disabled', true);
          });

          });

          <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

          <body>
          <div class="buttonWrapper">
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="1" data-pika-day="1">Month=1, Day=1</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="5" data-pika-day="1">Month=5, Day=5</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="2" data-pika-day="2">Month=2, Day=2</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="3" data-pika-day="4">Month=3, Day=4</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="4" data-pika-day="4">Month=4, Day=4</button>
          </div>
          <input type="text" id="username" />
          </body>





          $(function() {

          $("#username").on('change', '.buttonWrapper', function() {
          $('.pika-button:not([data-pika-day=1])').prop('disabled', true);
          });

          });

          <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

          <body>
          <div class="buttonWrapper">
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="1" data-pika-day="1">Month=1, Day=1</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="5" data-pika-day="1">Month=5, Day=5</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="2" data-pika-day="2">Month=2, Day=2</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="3" data-pika-day="4">Month=3, Day=4</button>
          <button class="pika-button pika-day" type="button" data-pika-year="2018" data-pika-month="4" data-pika-day="4">Month=4, Day=4</button>
          </div>
          <input type="text" id="username" />
          </body>






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 25 '18 at 11:04

























          answered Nov 25 '18 at 9:41









          GutelaunetypGutelaunetyp

          15010




          15010













          • didn't work. also, i don't really want to remove the options, since i would like them to be re-enabled if the username changes to something that doesn't fall under the condition

            – Bobert1234
            Nov 25 '18 at 10:29





















          • didn't work. also, i don't really want to remove the options, since i would like them to be re-enabled if the username changes to something that doesn't fall under the condition

            – Bobert1234
            Nov 25 '18 at 10:29



















          didn't work. also, i don't really want to remove the options, since i would like them to be re-enabled if the username changes to something that doesn't fall under the condition

          – Bobert1234
          Nov 25 '18 at 10:29







          didn't work. also, i don't really want to remove the options, since i would like them to be re-enabled if the username changes to something that doesn't fall under the condition

          – Bobert1234
          Nov 25 '18 at 10:29






















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53466150%2fdynamically-disabling-days-in-pikaday-datepicker%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          TypeError: fit_transform() missing 1 required positional argument: 'X'