I am having issues with html.textboxfor when i have to insert a decimal into my db, which is also set to a decimal.
i have tried this:
[RegularExpression(@"^[0-9]+(\.[0-9]{1,3})$", ErrorMessage = "Valid Decimal number with maximum 3 decimal places.")]
but it will only accept it if i have at least 3 decimals (1,123).
i need it to be able to accept, {1 - 1,2 - 1,23 - 1,234}
how do i achieve this ?
i have not been able to find a regularexpression generator which i could figure out how to use..
or am i in completely the wrong direction as to how i am going to solve my issue?
my value in the model:
[RegularExpression(@"^[0-9]+(\.[0-9]{1,3})$", ErrorMessage = "Valid Decimal number with maximum 3 decimal places.")]
[Required]
public decimal Average { get; set; }
input html in my form:
<div class="form-group">
@Html.LabelFor(x => x.Average, "Gennemsnit")
@Html.TextBoxFor(x => x.Average, new { @class = "form-control" })
@Html.ValidationMessageFor(x => x.Average, "", new { @class = "text-danger" })@
</div>