Attached is a reprex -- the link leads to Google. If you enter "test" in the input, it greys out the text input so you are unable to change it. However, if you enter any 4 character string but "test" (ie if you put in the wrong code, or make a typo), the label changes (indicating that the code is incorrect) and you are still able to type in the box, but the link is no longer active. I'm trying to make it so that if the code is entered incorrectly, you are still able to click the link (I'm imagining a use case where someone clicks the link, performs the task and then accidentally pastes the code into the wrong box, which would mean that they no longer have the option to click the link to the next task).
library(shiny)
ui <- fluidPage(
shinyjs::useShinyjs(),
# Application title
titlePanel("Title"),
# instructions
mainPanel(
fluidRow(
column(7,
textInput("taskA",a("Task A", href = 'https://www.google.com', target = "_blank"))
))
)
)
server <- function(input, output, session) {
observeEvent(input$taskA,{
if (input$taskA == "test"){
updateTextInput(session,"taskA", label = "Task A")
shinyjs::toggleState("taskA")
} else if(nchar(input$taskA) >= 4){
updateTextInput(session,"taskA", label = "Task A - please try code again")
}
})
}
# Run the application
shinyApp(ui = ui, server = server)