Reputation: 3123
I'm making a shiny app with dateRangeInput
. I want to make the date selection in such a way, that the user cannot select smaller date in second date input than first date input.
For example from the above image, shiny
now let's user select dates from 2017 in second date input after having selected July 26,2018 in first date input. I now want to make changes such that second date input always starts a day after first date input, like user can't select or even see July 26,2018 in second input and always sees a day after that like July 27,2018, after selecting July 26,2018 in first date input. I've check documentation for dateRangeInput
, nothing such was available there.
So, how do i do this?
Upvotes: 3
Views: 785
Reputation: 12819
An alternative to prevent user from selecting start > end can be found in shinyWidgets:
library(shiny)
ui <- fluidPage(
shinyWidgets::airDatepickerInput("daterange", "Date range:",
range = TRUE,
value = c("2010-01-01", "2001-12-31")),
verbatimTextOutput("res")
)
server <- function(input, output, session) {
output$res <- renderPrint({
paste("Start at", input$daterange[1], "and end at", input$daterange[2])
})
}
shinyApp(ui, server)
Upvotes: 7