我有一个模型,上面有几个属性。
数量是整数,宽度是小数。
在我的表格中我有
<InputNumber id="qty" class="form-control" maxLength="10" @bind-Value="_addModel.Quantity" placeholder="Quantity" />
<ValidationMessage For="@(() => _addModel.Quantity)" />
<InputNumber id="width" class="form-control" maxlength="50" @bind-Value="_addModel.Width" placeholder="Width (m)" />
<ValidationMessage For="@(() => _addModel.Width)" />
在这两种情况下,默认验证消息都显示为“数量字段必须是数字”或“宽度字段必须是数字”
如果我添加
[Range(1, 9999999999, ErrorMessage = "The Quantity must be a whole
number")]
发送给我的模型,然后我会收到两条消息。
如果我删除所有<ValidationSummary/>
,我仍然会收到两条消息。
对于数量我真的想说“数量字段必须是整数”。如何更改默认错误值。
好吧我终于找到答案了。我将其放在这里供其他遇到此问题的人使用。
在
ParsingErrorMessage="Quantity must be whole number"