如何限制 Shiny 应用程序中 textInput 接受的字符数 [英] How to limit the number of characters accepted by textInput in Shiny app

查看:34
本文介绍了如何限制 Shiny 应用程序中 textInput 接受的字符数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的 Shiny 应用程序(在 R 中)限制用户可以输入的字符数以响应 textInput 命令.

I would like my Shiny app (in R) to limit the number of characters a user can input in response to a textInput command.

我可以要求用户限制为 50 个字符,如果他不这样做,可以让应用向他发送消息,但如果他首先被阻止超过限制会更好.

I can request the user to limit to 50 characters and can have the app send him a message if he does not, but it would be better if he were prevented from overrunning the limit in the first place.

感谢建议.

推荐答案

你不能给 textInput 添加自定义属性,你可能可以编写自定义函数来生成输入,但在 javascript 中这样做会更容易:

You can't add custom attribute to textInput, you could probably be able to write custom function to generate input, but it will be easier to do this in javascript:

shinyjs::runjs("$('#inputName').attr('maxlength', 50)")

这篇关于如何限制 Shiny 应用程序中 textInput 接受的字符数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆