Salsa Calendar is a standalone pure JavaScript library created to generate date (range) pickers for hotel booking applications.
npm install salsa-calendar
`Create the check-in, check-out date inputs and number of nights span as follows:
`
(
)
`Initialize the date picker:
`
var calendar_from = new SalsaCalendar({
inputId: 'checkin',
lang: 'en',
range: {
min: 'today'
},
calendarPosition: 'right',
fixed: false,
connectCalendar: true
});var calendar_to = new SalsaCalendar({
inputId: 'checkout',
lang: 'en',
range: {
min: 'today'
},
calendarPosition: 'right',
fixed: false
});
`Setup the connection between these two date inputs and output the total of nights you user picked:
`
new SalsaCalendar.Connector({
from: calendar_from,
to: calendar_to,
maximumInterval: 21,
minimumInterval: 1
});new SalsaCalendar.NightsCalculator({
from: calendar_from,
to: calendar_to,
nightsNo: 'nights-no'
});
``