In the process of developing a basic application, I am seeking to implement a pop-up notification for invalid inputs. By referencing the suggestion provided in #1656, I have come up with an example that introduces a visually appealing background color when dealing with invalid inputs (especially considering my 300 variables):
library(shiny)
ui <- fluidPage(
tags$style(HTML("
input:invalid {
background-color: #FFCCCC;
}")),
numericInput("myValue", "My Variable", min = 0, max = 1, value = 0.5),
numericInput("myValue2", "My Variable2", min = 0, max = 3, step = 0.5, value = 0.5),
textOutput("text"),
textOutput("text2")
)
server <- function(input, output) {
output$text <- renderText(input$myValue)
output$text2 <- renderText(input$myValue2)
}
shinyApp(ui, server)
Although the
tags$style("input:invalid{ ... }")),
method is effective, I am interested in implementing a bootstrap alert instead of solely modifying the background color.
Essentially, I would like to incorporate the following div class within the input:invalid{}
section (considering the extensive list of 300 variables to validate):
<div class="alert alert-danger">
<strong>Danger!</strong> Indicates a dangerous or potentially negative action.
</div>
I would greatly appreciate any input or recommendations on how to achieve this desired functionality.