Blazorise icon indicating copy to clipboard operation
Blazorise copied to clipboard

[Bug]: Validation on InputMask is not kicking off and binds the input mask

Open sturlath opened this issue 1 year ago • 3 comments
trafficstars

Blazorise Version

1.3.2

What Blazorise provider are you running on?

Bootstrap5

Link to minimal reproduction, or a simple code snippet

I might be doing this wrong but I have this code

<Fields>
    <Validation MessageLocalizer="@Localize">
        <Field ColumnSize="ColumnSize.Is3.OnDesktop.Is3.OnWidescreen">
            <FieldBody>
                <FieldLabel>@L["Kennitala"]</FieldLabel>
                <InputMask Mask="999999-9999" @bind-Value="@BankInformation.Kennitala" >
                     <Feedback>
                        <ValidationError />
                    </Feedback>
             </InputMask>       
            </FieldBody>
        </Field>
    </Validation>
</Fields>

with

  [Required(ErrorMessage = "Required")]
  [StringLength(11, ErrorMessage = "Mustbebetween10and11characters", MinimumLength = 10)]
  public string Kennitala { get; set; }

but only the Required part is validated but not the MinimumLength one image

and what happens is that this value gets safed 3_____-____

Steps to reproduce

see above

What is expected?

The validation should kick off and not allow the mask value to be bound.

What is actually happening?

Only one value is enough to get past the validation and bind to the inputmask...

What browsers are you seeing the problem on?

Microsoft Edge

Any additional comments?

No response

sturlath avatar Dec 10 '23 13:12 sturlath

I suspect that the Value of the InputMask always has _ as part of the mask value. So the final Value will always have 11 characters which can be considered a valid value.

Can you try setting the AutoUnmask="true" so that the _ are stripped away?

stsrki avatar Jan 12 '24 16:01 stsrki

That didn´t solve it

image

sturlath avatar Jan 14 '24 11:01 sturlath