Watch on YouTube
How to set max length of integer
1. Metadata file
namespace MVCValidationTest.Models
{
[MetadataType(typeof(SelectTestValidation_Metadata))]
public partial class SelectTestValidation_Result
{
//[StringLength(3, ErrorMessage = "{0} cannot be longer than 3 chars")]
[Range(1,999)]
public int test { get; set; }
2. View
@Html.TextBoxFor(x => x.test, new { maxlength = 3 })
No comments:
Post a Comment