I have the following property in my view model:
[Required]
[MaxLength(12)]
[MinLength(1)]
[RegularExpression(\"[^0-9]\", ErrorMessage = \"UPRN must be numeri
The RegEx should be ^[0-9]*$
.
I.E.
The property should look like:
[Required]
[MaxLength(12)]
[MinLength(1)]
[RegularExpression("^[0-9]*$", ErrorMessage = "UPRN must be numeric")]
public string Uprn { get; set; }
See working example.
I'm sure you already have jQuery referenced but make sure jQuery validate and Microsoft validate scripts are included.