【问题标题】:jQuery Mask Plugin with r shiny textInput带有 r 闪亮 textInput 的 jQuery 掩码插件
【发布时间】:2018-11-17 15:36:38
【问题描述】:

有没有办法用R-Shiny textInput 做类似jQuery Mask Plugin 的事情?

我正在尝试让textInput 在我输入时显示一个掩码。

示例:我想输入 11111111111,当我输入时,textInput 值显示为 111.111.111-11。

有什么想法吗?

【问题讨论】:

    标签: r shiny shinydashboard textinput jquery-mask


    【解决方案1】:

    你的意思是这样的吗? 或者更花哨的东西? ;)

    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, 12), ".",
                         stri_sub(textout, 13, 14), ".")
    
        print(textout)
      })
    }
    
    shinyApp(ui, server)
    

    【讨论】:

    • 感谢您的回答,但我真的在想更花哨的东西。我希望能够以 textInput 显示掩码的方式输入 textInput(或类似的东西),因为我不是在常规的 textOutput 中输入,而是在我输入的同一个空间中。我不知道它是否可能。我想在 Shiny 中重现的效果可以在 jQuery Mask Plugin (igorescobar.github.io/jQuery-Mask-Plugin) 中观察到。
    猜你喜欢
    • 2021-04-10
    • 2016-09-22
    • 2021-06-15
    • 1970-01-01
    • 2016-01-30
    • 2015-11-16
    • 1970-01-01
    • 2020-06-16
    • 2017-07-25
    相关资源
    最近更新 更多