【发布时间】:2021-12-21 16:34:13
【问题描述】:
我试图在一个按钮上创建一个条件,所以它只在我的输入为 not empty AND is numeric 时才有效。 我的代码部分起作用,因为当输入输入时按钮以禁用状态启动,但即使输入不是数字(即输入字母将启用按钮)
用户界面
library(shinyjs)
ui <- tabItem(tabName = "principal1",
br(),
fluidRow(
column(2,
textInput(inputId = "documento1", "Ingrese el numero de documento", "")
),
column(2,
br(),
fluidRow(
actionButton("consulta_gobutton1",
label = "Procesar",
icon = icon("clipboard-check") ) )))
服务器端
observeEvent(input$consulta_gobutton1, {
documento1 <- input$documento1
###HERE IS MY CODE###
})
observe({
toggleState("consulta_gobutton1", input$documento1 != "" & is.numeric(as.numeric(input$documento1)) )
})
【问题讨论】: