Disable date selection by setting the current date - DatePicker












0















as written in the title I have implemented two DatePicker.
Via MDBootstrap: (https://mdbootstrap.com/docs/jquery/forms/date-picker/).



My intent was to not allow the user to select a date that is before the current date.



I have searched in their support, but no command corresponds to what interests me.



In addition, what I would like the second DatePicker, can not select a date that occurred before the date that is selected in the first DatePicker.



The code is here on JSFiddle.



The part of Javascript, you can call it how you want for the test.



Thank you all.










share|improve this question





























    0















    as written in the title I have implemented two DatePicker.
    Via MDBootstrap: (https://mdbootstrap.com/docs/jquery/forms/date-picker/).



    My intent was to not allow the user to select a date that is before the current date.



    I have searched in their support, but no command corresponds to what interests me.



    In addition, what I would like the second DatePicker, can not select a date that occurred before the date that is selected in the first DatePicker.



    The code is here on JSFiddle.



    The part of Javascript, you can call it how you want for the test.



    Thank you all.










    share|improve this question



























      0












      0








      0








      as written in the title I have implemented two DatePicker.
      Via MDBootstrap: (https://mdbootstrap.com/docs/jquery/forms/date-picker/).



      My intent was to not allow the user to select a date that is before the current date.



      I have searched in their support, but no command corresponds to what interests me.



      In addition, what I would like the second DatePicker, can not select a date that occurred before the date that is selected in the first DatePicker.



      The code is here on JSFiddle.



      The part of Javascript, you can call it how you want for the test.



      Thank you all.










      share|improve this question
















      as written in the title I have implemented two DatePicker.
      Via MDBootstrap: (https://mdbootstrap.com/docs/jquery/forms/date-picker/).



      My intent was to not allow the user to select a date that is before the current date.



      I have searched in their support, but no command corresponds to what interests me.



      In addition, what I would like the second DatePicker, can not select a date that occurred before the date that is selected in the first DatePicker.



      The code is here on JSFiddle.



      The part of Javascript, you can call it how you want for the test.



      Thank you all.







      javascript jquery






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 16 '18 at 10:39









      Hamza Abdaoui

      1,53321122




      1,53321122










      asked Nov 16 '18 at 10:28









      okokokok

      32




      32
























          3 Answers
          3






          active

          oldest

          votes


















          0














          You can try with min and max property of MDBootstrap. here i am using min function to achieve your task.



          <div class="md-form">
          <input placeholder="Selected date" type="text" id="date-picker-example" class="form-control datepicker">
          <input placeholder="Selected date" type="text" id="date-picker-example2" class="form-control">
          <label for="date-picker-example">Try me...</label>
          </div>

          // Data Picker Initialization
          $('.datepicker').pickadate({
          min : new Date(),
          onClose: function(){
          $('#date-picker-example2').pickadate({
          min : $('.datepicker').val()
          })
          }
          });


          you can see example here



          for more options you can refer this document






          share|improve this answer
























          • vote up if it resolve your problem.

            – Negi Rox
            Nov 16 '18 at 11:13



















          0














          Try adding



          minDate: new Date()


          into your DatePicker initialiser function






          share|improve this answer































            0














            You can add something like this make your datepicker disable dates before current date



            $('.datepicker').pickadate({ 
            min: new Date(),
            });


            It seems like if your second date picker reacts with the changes of the first one then there might be the name conflict.






            share|improve this answer


























            • unfortunately it does not work, it allows me to be able to select dates past today

              – okok
              Nov 16 '18 at 10:41











            • he is talking about MDbootstrap

              – Negi Rox
              Nov 16 '18 at 10:43












            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%2f53335947%2fdisable-date-selection-by-setting-the-current-date-datepicker%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            You can try with min and max property of MDBootstrap. here i am using min function to achieve your task.



            <div class="md-form">
            <input placeholder="Selected date" type="text" id="date-picker-example" class="form-control datepicker">
            <input placeholder="Selected date" type="text" id="date-picker-example2" class="form-control">
            <label for="date-picker-example">Try me...</label>
            </div>

            // Data Picker Initialization
            $('.datepicker').pickadate({
            min : new Date(),
            onClose: function(){
            $('#date-picker-example2').pickadate({
            min : $('.datepicker').val()
            })
            }
            });


            you can see example here



            for more options you can refer this document






            share|improve this answer
























            • vote up if it resolve your problem.

              – Negi Rox
              Nov 16 '18 at 11:13
















            0














            You can try with min and max property of MDBootstrap. here i am using min function to achieve your task.



            <div class="md-form">
            <input placeholder="Selected date" type="text" id="date-picker-example" class="form-control datepicker">
            <input placeholder="Selected date" type="text" id="date-picker-example2" class="form-control">
            <label for="date-picker-example">Try me...</label>
            </div>

            // Data Picker Initialization
            $('.datepicker').pickadate({
            min : new Date(),
            onClose: function(){
            $('#date-picker-example2').pickadate({
            min : $('.datepicker').val()
            })
            }
            });


            you can see example here



            for more options you can refer this document






            share|improve this answer
























            • vote up if it resolve your problem.

              – Negi Rox
              Nov 16 '18 at 11:13














            0












            0








            0







            You can try with min and max property of MDBootstrap. here i am using min function to achieve your task.



            <div class="md-form">
            <input placeholder="Selected date" type="text" id="date-picker-example" class="form-control datepicker">
            <input placeholder="Selected date" type="text" id="date-picker-example2" class="form-control">
            <label for="date-picker-example">Try me...</label>
            </div>

            // Data Picker Initialization
            $('.datepicker').pickadate({
            min : new Date(),
            onClose: function(){
            $('#date-picker-example2').pickadate({
            min : $('.datepicker').val()
            })
            }
            });


            you can see example here



            for more options you can refer this document






            share|improve this answer













            You can try with min and max property of MDBootstrap. here i am using min function to achieve your task.



            <div class="md-form">
            <input placeholder="Selected date" type="text" id="date-picker-example" class="form-control datepicker">
            <input placeholder="Selected date" type="text" id="date-picker-example2" class="form-control">
            <label for="date-picker-example">Try me...</label>
            </div>

            // Data Picker Initialization
            $('.datepicker').pickadate({
            min : new Date(),
            onClose: function(){
            $('#date-picker-example2').pickadate({
            min : $('.datepicker').val()
            })
            }
            });


            you can see example here



            for more options you can refer this document







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 16 '18 at 10:43









            Negi RoxNegi Rox

            1,8861511




            1,8861511













            • vote up if it resolve your problem.

              – Negi Rox
              Nov 16 '18 at 11:13



















            • vote up if it resolve your problem.

              – Negi Rox
              Nov 16 '18 at 11:13

















            vote up if it resolve your problem.

            – Negi Rox
            Nov 16 '18 at 11:13





            vote up if it resolve your problem.

            – Negi Rox
            Nov 16 '18 at 11:13













            0














            Try adding



            minDate: new Date()


            into your DatePicker initialiser function






            share|improve this answer




























              0














              Try adding



              minDate: new Date()


              into your DatePicker initialiser function






              share|improve this answer


























                0












                0








                0







                Try adding



                minDate: new Date()


                into your DatePicker initialiser function






                share|improve this answer













                Try adding



                minDate: new Date()


                into your DatePicker initialiser function







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 16 '18 at 10:41









                Neil RNeil R

                16




                16























                    0














                    You can add something like this make your datepicker disable dates before current date



                    $('.datepicker').pickadate({ 
                    min: new Date(),
                    });


                    It seems like if your second date picker reacts with the changes of the first one then there might be the name conflict.






                    share|improve this answer


























                    • unfortunately it does not work, it allows me to be able to select dates past today

                      – okok
                      Nov 16 '18 at 10:41











                    • he is talking about MDbootstrap

                      – Negi Rox
                      Nov 16 '18 at 10:43
















                    0














                    You can add something like this make your datepicker disable dates before current date



                    $('.datepicker').pickadate({ 
                    min: new Date(),
                    });


                    It seems like if your second date picker reacts with the changes of the first one then there might be the name conflict.






                    share|improve this answer


























                    • unfortunately it does not work, it allows me to be able to select dates past today

                      – okok
                      Nov 16 '18 at 10:41











                    • he is talking about MDbootstrap

                      – Negi Rox
                      Nov 16 '18 at 10:43














                    0












                    0








                    0







                    You can add something like this make your datepicker disable dates before current date



                    $('.datepicker').pickadate({ 
                    min: new Date(),
                    });


                    It seems like if your second date picker reacts with the changes of the first one then there might be the name conflict.






                    share|improve this answer















                    You can add something like this make your datepicker disable dates before current date



                    $('.datepicker').pickadate({ 
                    min: new Date(),
                    });


                    It seems like if your second date picker reacts with the changes of the first one then there might be the name conflict.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Nov 16 '18 at 10:48

























                    answered Nov 16 '18 at 10:34









                    ram vinothram vinoth

                    37129




                    37129













                    • unfortunately it does not work, it allows me to be able to select dates past today

                      – okok
                      Nov 16 '18 at 10:41











                    • he is talking about MDbootstrap

                      – Negi Rox
                      Nov 16 '18 at 10:43



















                    • unfortunately it does not work, it allows me to be able to select dates past today

                      – okok
                      Nov 16 '18 at 10:41











                    • he is talking about MDbootstrap

                      – Negi Rox
                      Nov 16 '18 at 10:43

















                    unfortunately it does not work, it allows me to be able to select dates past today

                    – okok
                    Nov 16 '18 at 10:41





                    unfortunately it does not work, it allows me to be able to select dates past today

                    – okok
                    Nov 16 '18 at 10:41













                    he is talking about MDbootstrap

                    – Negi Rox
                    Nov 16 '18 at 10:43





                    he is talking about MDbootstrap

                    – Negi Rox
                    Nov 16 '18 at 10:43


















                    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%2f53335947%2fdisable-date-selection-by-setting-the-current-date-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

                    Xamarin.iOS Cant Deploy on Iphone

                    Glorious Revolution

                    Dulmage-Mendelsohn matrix decomposition in Python