【问题标题】:How to limit the number of characters in @Html.TextArea?如何限制@Html.TextArea 中的字符数?
【发布时间】:2017-09-13 13:13:57
【问题描述】:

有这行代码:

@Html.TextArea("userInput")

如何限制userInput中的字符数?

【问题讨论】:

    标签: html html-helper


    【解决方案1】:

    这应该可行。

    @Html.TextArea("userInput",new { maxlength=50 })

    【讨论】:

      【解决方案2】:

      https://www.w3schools.com/tags/att_textarea_maxlength.asp

      textarea 有一个“maxlength”属性,它完全符合您的要求。如果此文本要进入某处的服务器或某些客户端 JavaScript,我建议也验证该代码中的长度。然而。最大长度属性足以显示。

      【讨论】:

        猜你喜欢
        • 2016-03-02
        • 2011-03-31
        • 1970-01-01
        • 2012-11-28
        • 1970-01-01
        • 2012-05-22
        • 1970-01-01
        • 2015-04-12
        • 1970-01-01
        相关资源
        最近更新 更多