Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

how to change the default error message for int on blazor validator

$
0
0

I have a model with a couple of properties on them.

Quantity is an int whilst width is a decimal.

In my form I have

<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)" />

in both cases the default validation message shows as 'The quantity field must be a number' or 'The Width field must be a number'

If I add

 [Range(1, 9999999999, ErrorMessage = "The Quantity must be a whole number")]

to my model, then I receive both messages.

if I remove all the <ValidationMessage attributes and replace with a single <ValidationSummary/> I still receive both messages.

For Quantity I really want to say 'The quantity field must be a whole number'. how can I change the default error value.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>