library(shiny)
ui <- fluidPage(
title = "App Title",
textInput("text","enter here"),
uiOutput("text1")
)
max = 10
server <- function(session,input, output)
{
output$text1 <- reactive({ paste0('only ', max-nchar(input$text), ' characters left' ) })
observeEvent(input$text,{
if(nchar(input$text) > max ) {
updateTextInput(session , "text",value = substr(input$text,1,max))
}
})
}
shinyApp(ui=ui,server=server)
what should I do to stop the cursor when it reaches to the max length provided.I don't need any notification or alert box just the cursor stops and move backward to erase the text.
observeEvent(input$text,{
if(nchar(input$text) > max ) {
updateTextInput(session , "text",value = substr(input$text,1,max))
}
})
what things should I change to work like it.. took a reference from Add character limit to a text box in an R shiny app
Thank You in advance