0

I took over support for a Blazor application using .NET Core 3.1 and I have added code for validation but I have validation messages showing for some controls that have no validation attributes or ValidationMessage tags, and validation messages show where I do have the attributes and validation message tags as expected. I have no idea why messages are showing were there isn't an attribute or validation message tag. The message is displayed for the GasComps[0].Quantity shown below. The message is stating that the numbers need to be whole numbers, because if I change the value to 1.5 the message states the nearest valid values are 0 and 1. I cannot find any place in the code were it appears that this type of validation is desired. I cannot figure out what is triggering this behavior.

Any suggestions or ideas?

Here is a screen shot of the message shown upon submit.

enter image description here

Razor Code snippet

<EditForm Model="@Values" OnValidSubmit="HandleValidSubmit">
    <DataAnnotationsValidator />

    <div class="row">
        <div class="col-lg-2">
            <p class="text-center">@GasComps[0].ID</p>
        </div>
        <div class="col-lg-2">
            <p class="text-center">@GasComps[0].Name</p>
        </div>
        <div class="col-lg-2">
            <p class="text-center">@GasComps[0].AMW</p>
        </div>
        <div class="col-lg-2">
            <input type="number" class="form-control text-center" @bind="GasComps[0].Quantity" />
        </div>
        <div class="col-lg-2">
            <p class="text-center">@GasComps[0].WtFraction</p>
        </div>
    </div>

    <div class="row">
        <div class="col-1">
            <button type="submit" class="btn btn-success">Calculate</button>
        </div>

Model Code snippet

public double Quantity { get; set; }
0

1 Answer 1

2

Set step to any. This is default validation behaviour for <input type=number ... /> .

<input type="number" class="form-control text-center" @bind="GasComps[0].Quantity" step="any" />

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Brian Parker, I figured it was some default behavior but I couldn't find the right Google question to ask that would point me in the right direction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.