How to set a number range validation in html.textb

2019-06-21 07:42发布

Code:

@Html.TextBoxFor(x => x.PercentNos, new {@class = "percentage-numbers"})

How to set the numbers limit 0 to 100 in @html.textboxfor in cshtml view page in mvc4?

1条回答
别忘想泡老子
2楼-- · 2019-06-21 08:48

You can use the Range attribute to limit the input from 0 to 100. You apply this attribute to the (target) property of the model you are using in your view.

[Range(0,100)]
public int PercentNos { get; set; }
查看更多
登录 后发表回答