【问题标题】:How to limit filed length in razor template with type number?如何使用类型号限制剃刀模板中的字段长度?
【发布时间】:2018-08-20 03:06:03
【问题描述】:

这个我试过了,还是不行

@Html.EditorFor(model => model.discount, new { htmlAttributes = new { @class = "form-control", @type = "number", @step = "0.01", @min = "1", @max = "99999" } })

【问题讨论】:

    标签: html razor


    【解决方案1】:

    @minlength="10",@maximumlength="10" 你可以使用 textboxfor 或 editorfor 什么都行……

    【讨论】:

      【解决方案2】:

      使用maxlengthTextBoxFor 代替EditorFor

      EditorFor 没有允许这样做的重载。

      这对你来说可能更有趣: maxlength attribute of a text box from the DataAnnotations StringLength in Asp.Net MVC

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-12-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-07-31
        • 1970-01-01
        • 1970-01-01
        • 2012-01-24
        相关资源
        最近更新 更多