Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How use data annotations for verifying input particular type

Tags:

c#

asp.net-mvc

User must input in form only integers. How use data annotations for verifying ?

like image 481
dev85 Avatar asked Mar 01 '12 19:03

dev85


2 Answers

Try this out:

[Range(0, Int32.MaxValue, ErrorMessage="Invalid Number")]
public int? Number { get; set; }
like image 65
Amen Ayach Avatar answered Sep 20 '22 12:09

Amen Ayach


Have a look at the Data Annotations Extensions which includes an Integer attribute.

like image 28
devdigital Avatar answered Sep 22 '22 12:09

devdigital