Is there a way to do something like jQuery Mask Plugin with a RShiny textInput
?
The goal is to make a textInput
display a mask (inside the textInput
) as teh user is typing.
Exemple: I want to type 11111111111 and, as I type, the textInput value displays 111.111.111-11 (brazilian CPF format).
The textOutput("text")
at the app below outputs what I want to happen at the textInput
box while I'm typing,
Any ideas?
library(shiny)
library(stringi)
ui <- fluidPage(
textInput("textin", "Enter Text"),
textOutput("text")
)
server <- function(input, output) {
output$text <- renderText({
textout <- input$textin
textout <- paste(stri_sub(textout, 1, 3),".",
stri_sub(textout, 4, 6), ".",
stri_sub(textout, 7, 9), "-",
stri_sub(textout, 10, 11))
print(textout)
})
}
shinyApp(ui, server)