Restrictions on an input of type date

1

I am new to Javascript, and I can not find a way for the user to only select dates +2 days of the current day, and that Saturday and Sunday are not available. The only thing I found was how to give maximum and minimum dates

Does anyone know how to do this?

    
asked by Damian Ricobelli 04.11.2018 в 03:53
source

2 answers

0

Ok, I was able to find the solution to the problem using the bootstrap datepicker!

What you have to do is include the .js and .css files of the datepicker, and then place, for example, a code like the following:

<div class="form-group">

                    <div class="input-group date nf-date">

                        <span class="input-group-addon">

                            <i class="glyphicon glyphicon-calendar"></i>

                        </span>

                        <input type="text" class="form-control" id="registroCalendario" name="registroCalendario" placeholder="Día de envío" required>

                    </div>

                </div>

That would be the field that contains the calendar inside the form. Then, in Javascript you can do the following:

/*=============================================
CALENDARIO BOOTSTRAP
=============================================*/

$('.nf-date').datepicker({
    format: "dd/mm/yyyy",
    weekStart: 0,
    startDate: "+2d",
    endDate: "+30d",
    clearBtn: true,
    language: "es",
    multidate: false,
    daysOfWeekDisabled: "0,6",
    autoclose: true,
    todayHighlight: true
});

With startDate: "+ 2d" I tell you that it is only available from 2 days after the current date, and with daysOfWeekDisabled: "0.6" I disable Saturdays and Sundays.

    
answered by 04.11.2018 / 04:09
source
2

You can do it like this:

<input type="date" name="bday" max="2018-11-05" min="2018-11-03">

Min: for the minimum possible Max: for the maximum possible I hope you serve

    
answered by 04.11.2018 в 04:00