48 lines
1.2 KiB
R
48 lines
1.2 KiB
R
#' Set the maximum length on a text or textarea input
|
|
#'
|
|
#' @param input The Shiny input to set the length attribute on
|
|
#' @param length The maximum length allowed on the input
|
|
#'
|
|
#' @return The modified input
|
|
#' @export
|
|
#'
|
|
#' @examples
|
|
#' x <- shiny::textInput("input_id", "Some text input")
|
|
#' htmlSetMaxLength(x, 50)
|
|
htmlSetMaxLength <- function(input, length) {
|
|
htmltools::tagQuery(input)$
|
|
find(".shiny-input-password")$
|
|
addAttr(maxlength = length)$
|
|
reset()$
|
|
find(".shiny-input-text")$
|
|
addAttr(maxlength = length)$
|
|
reset()$
|
|
find("textarea")$
|
|
addAttr(maxlength = length)$
|
|
allTags()
|
|
}
|
|
|
|
#' Set the minimum length on a text or textarea input
|
|
#'
|
|
#' @param input The Shiny input to set the length attribute on
|
|
#' @param length The minimum length allowed on the input
|
|
#'
|
|
#' @return The modified input
|
|
#' @export
|
|
#'
|
|
#' @examples
|
|
#' x <- shiny::textInput("input_id", "Some text input")
|
|
#' htmlSetMinLength(x, 3)
|
|
htmlSetMinLength <- function(input, length) {
|
|
htmltools::tagQuery(input)$
|
|
find(".shiny-input-password")$
|
|
addAttr(minlength = length)$
|
|
reset()$
|
|
find(".shiny-input-text")$
|
|
addAttr(minlength = length)$
|
|
reset()$
|
|
find("textarea")$
|
|
addAttr(minlength = length)$
|
|
allTags()
|
|
}
|