This is a commonly asked question. But I am not getting the answer that I need. I had a look at MVC Validation make RegularExpression numeric only on string field (among many) for reference but I am not quite there yet.
I have an html5 input field bound to an MVC property. I want to make use of the [RegularExpression()]
attribute but I am not getting the output that I need. I need my input to only take the following:
A single number between 0
and 7
, or the %
character
I tried the following:
[RegularExpression("^[0-7][%]")]
.
Where am I going wrong?