问题验证器使用langage用时使用ABP模式的形式的小数为小数字段

发布于 2025-02-04 17:59:38 字数 919 浏览 5 评论 0原文

用包含一个十进制属性的模型来描述错误

,这与使用小数逗号的语言环境不起作用:代码:

<input asp-for="Number">
<input asp-for="Number" type="number">

代码: 我被使用模式显示我的表单和一个ViewModel:

class ViewModel 
{
           [StringLength(56)]
           public string Speciality { get; set; }

           [StringLength(128)]
           public string StructureLinked { get; set; }

           [Required]
           [AbpRadioButton(Inline = true)]
           public RateType RateSelected { get; set; }

           [HiddenInput]
           public decimal RateGeneral { get; set; }

           public decimal RateSpecific { get; set; }
}

第一个问题是其余表格返回法国验证器langage,但对于使用DECIMAL的所有属性,验证器都是英语。 第二个问题是,我们在没有逗号的情况下提供了数据,它可以正确发送和接收。但是,如果我们尊重英语格式9.8我们接收0

我试图强迫文件的加载jqueryvalidator/message_fr.js或在Web上找到的一些不同的修复程序而没有成功

Describe the bug

With a model that contains a decimal property, this doesn't work with a locale that uses a decimal comma:

<input asp-for="Number">
<input asp-for="Number" type="number">

Code:
I am used a modal for display my form and a ViewModel:

class ViewModel 
{
           [StringLength(56)]
           public string Speciality { get; set; }

           [StringLength(128)]
           public string StructureLinked { get; set; }

           [Required]
           [AbpRadioButton(Inline = true)]
           public RateType RateSelected { get; set; }

           [HiddenInput]
           public decimal RateGeneral { get; set; }

           public decimal RateSpecific { get; set; }
}

The first issue is that the rest of the form return french validator langage as expected, but for all the properties which use decimal the validator is in English.
The second issues is that we give a data without comma it's send and receive correctly. But if we respect the English format as 9.8 we receive 0.

I tried to force the loading of the file jqueryvalidator/message_fr.js or some differents fix find on web without success

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苍白女子 2025-02-11 17:59:38

这听起来像是这里描述的问题:
mvc/jquery not /a>

解决方案:

您可以覆盖本文中解释的jQuery验证:
oferwollow noreferrer“>

oferwrite jquery jquery jquery verator 您会将其添加到脚本中:

$.validator.methods.number = function (value, element) {
    return this.optional(element)
        || /^-?(?:\d+|\d{1,3}(?:\.\d{3})+)(?:[,.]\d+)?$/.test(value);
}

请注意,这仅可以修复客户端中的验证。 也可以在后端采用该辐射。

This sounds like the issue described here:
MVC/JQuery validation does not accept comma as decimal separator

Solution:

You can overwrite the jquery validation as explained in this post:
OverWrite jQuery Validator

To allow comma and dot seperator at the same time you would add this to your script:

$.validator.methods.number = function (value, element) {
    return this.optional(element)
        || /^-?(?:\d+|\d{1,3}(?:\.\d{3})+)(?:[,.]\d+)?$/.test(value);
}

Be aware that this only fixes the validation in your client. The valiation might also be adopted in the backend.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文