I have an ASP.NET web application, my view model has a double field PowerPrice, but the validation for the field goes off if the user doesn't enter a leading zero. The validation will say "please enter a number." How can I allow the user to enter ".11" instead of requiring "0.11"? Here is my view and model code:
<div class="editor-field">
@Html.EditorFor(model => model.PowerPrice)
@Html.ValidationMessageFor(model => model.PowerPrice)
</div>
public double PowerPrice
{
get;
set;
}
You are setting a value that is not of the right type in this case ".11" to an object of type Double. It will always fail.
You have a couple of options that I can think of off the top of my head.
Or,
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