【发布时间】:2017-09-13 13:13:57
【问题描述】:
有这行代码:
@Html.TextArea("userInput")
如何限制userInput中的字符数?
【问题讨论】:
标签: html html-helper
有这行代码:
@Html.TextArea("userInput")
如何限制userInput中的字符数?
【问题讨论】:
标签: html html-helper
这应该可行。
@Html.TextArea("userInput",new { maxlength=50 })
【讨论】:
https://www.w3schools.com/tags/att_textarea_maxlength.asp
textarea 有一个“maxlength”属性,它完全符合您的要求。如果此文本要进入某处的服务器或某些客户端 JavaScript,我建议也验证该代码中的长度。然而。最大长度属性足以显示。
【讨论】: