Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a number range validation in html.textboxfor in cshtml view page in mvc4?

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?

like image 688
John Stephen Avatar asked May 06 '13 07:05

John Stephen


1 Answers

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; }
like image 83
von v. Avatar answered Nov 15 '22 06:11

von v.