I'm using validations as below.
[Required(ErrorMessage = "Please provide 10 digit mobile number without spaces and without country code (+91)")]
[Integer(ErrorMessage = "Please provide 10 digit mobile number without spaces and without country code (+91)")]
[Range(1000000000, 9999999999, ErrorMessage = "10 digit mobile number only without spaces and without country code (+91)")]
[Display(Name = "Mobile Number")]
public int MobileNo { get; set; }
It is always failing the validations saying The value '9999999998' is invalid.. Am I doing something wrong?
Try this:
[RegularExpression("^[0-9]{10}$", ErrorMessage = "Invalid Mobile No")]
The maximum value that an Int32 type could store is 2,147,483,648. You are overflowing. Why are you using an integer type to represent a phone number? String seems more adapted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With