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

开启表单验证后,MTextField输入长数字页面报错 #1934

Closed
byte-book opened this issue May 28, 2024 · 2 comments
Closed

开启表单验证后,MTextField输入长数字页面报错 #1934

byte-book opened this issue May 28, 2024 · 2 comments
Labels

Comments

@byte-book
Copy link

Masa.Blazor version

1.5.2

Describe the bug

image

使用表单输入,开启表单验证,文本框设置类型为number,设置输入长度限制,给绑定对象设置范围
1、maxlength="25"不起作用,导致可以输入非常大的数字
2、当输入一个大数后,点击其他地方,再点击输入框,让输入框获得焦点,然后报错

<MForm Model="_model" EnableValidation EnableI18n>
    <MTextField Label="测试" Outlined TValue="float?" Suffix="mA" Type="number" maxlength="25" @bind-Value="_model.testValue"></MTextField>
    <MButton>设置</MButton>
    <MButton>取消</MButton>
</MForm>
    class Model
    {
        [Required]
        [Range(4, 20)]
        public float? testValue{ get; set; }
    }

Expected Behavior

No response

Steps To Reproduce

No response

Reproduction code

No response

.NET version

dotnet 8.0

What browsers are you seeing the problem on?

No response

Additional context

No response

@capdiem
Copy link
Contributor

capdiem commented May 28, 2024

@msmw13 maxlength 不是组件支持的属性,你需要设置:

<MTextField Type="number" NumberProps="n => n.Max = 25" />

@byte-book
Copy link
Author

@capdiem maxlength 在文本模式下有效,之前添加这个是为了解决报错问题,去掉也还会报错,不管绑定的类型是decimal或Int等数值类型。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants