5

have a nice date!!. In magento2 i tried set input type date and add confign min|maxDate. but is not success. Pls tell me how to set config.

this my code:

<input type="date" value="04-07-2016" class="type-date  hasDatepicker mage-error" max="20-07-2016" min="20-07-2011" name="date-854" aria-invalid="true">

<script>
 require(["jquery","mage/calendar", "mage/validation"],
 function($){
       var min = $(this).attr('min'),
           max = $(this).attr('max');
       $('input[type=date]').calendar({
            buttonText:"<?php echo __('Select Date') ?>",
            dateFormat: "dd-mm-yy",
            singleClick : true,
            minDate: min,
            maxDate: max,
         });

    $('#contact-form').validation();

});
</script>
| improve this question | | | | |
9

You should pass date in below format.

<input type="date" value="04-07-2016" class="type-date  hasDatepicker mage-error" max="20-07-2016" min="20-07-2011" name="date-854" aria-invalid="true">

<script>
 require(["jquery","mage/calendar", "mage/validation"],
 function($){
       var min = new Date("June 13, 2016"),
           max = new Date("July 25,2016");
       $('input[type=date]').calendar({
            buttonText:"<?php echo __('Select Date') ?>",
            dateFormat: "dd-mm-yy",
            singleClick : true,
            minDate: min,
            maxDate: max,
         });

    $('#contact-form').validation();

});
| improve this answer | | | | |
  • tks. it good work! – xanka Jul 18 '16 at 6:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.