Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sturlath opened this issue Dec 10, 2023 · 3 comments
Open
Assignees
Labels
Type: Bug 🐞 Something isn't working
Milestone

Comments

@sturlath
Copy link
Contributor

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 sturlath added the Type: Bug 🐞 Something isn't working label Dec 10, 2023
@stsrki stsrki added this to the 1.4 support milestone Dec 10, 2023
@steal4life steal4life self-assigned this Dec 13, 2023
@stsrki
Copy link
Collaborator

stsrki commented Jan 12, 2024

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?

@sturlath
Copy link
Contributor Author

That didn´t solve it

image

@stsrki stsrki added this to Support Aug 3, 2024
@stsrki stsrki moved this to 🔙 Backlog in Support Aug 3, 2024
@stsrki stsrki modified the milestones: 1.4 support, 1.6 support Oct 24, 2024
@stsrki stsrki modified the milestones: 1.6 support, 2.0 Jan 16, 2025
@stsrki stsrki removed this from Support Jan 16, 2025
@github-project-automation github-project-automation bot moved this to No Status in Development Jan 16, 2025
@stsrki stsrki assigned tesar-tech and unassigned steal4life Jan 16, 2025
@tesar-tech
Copy link
Collaborator

Hi @sturlath.
I am trying to reproduce the issue, but it really seems the AutoUnmask is the solution:

b3fad880-3d24-47cd-9434-a6204e6bac5c.mp4

It either has been fixed along the way between versions, or you have some specifics in your code, that I cannot reproduce.

Here is my full working code. .net9, server interactivity, Blazorise 1.7.2.

@page  "/im"
@using Blazorise
@using System.ComponentModel.DataAnnotations
<Validations Mode="ValidationMode.Auto" Model="@bankInfo">
    <Fields>
        <Validation >
            <Field ColumnSize="ColumnSize.Is3.OnDesktop.Is3.OnWidescreen">
                <FieldBody>
                    <FieldLabel>Label</FieldLabel>
                    <InputMask AutoUnmask Mask="999999-9999" @bind-Value="@bankInfo.Kennitala" >
                        <Feedback>
                            <ValidationError />
                        </Feedback>
                    </InputMask>
                </FieldBody>
            </Field>
        </Validation>
    </Fields>
</Validations>
@code {
    
    BankInformation bankInfo = new();

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

}

Please re-test and let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug 🐞 Something isn't working
Projects
Status: No Status
Development

No branches or pull requests

4 participants