【问题标题】:autoNumeric plugin error in asp.net MVC 5asp.net MVC 5 中的 autoNumeric 插件错误
【发布时间】:2015-10-16 14:35:15
【问题描述】:

我目前在我的应用程序中使用 autoNumeric。 它工作得很好。 但是,在编辑模式下,JQuery 显示此错误消息:

“设置”的值 ($ 100.000.00) 不是数字,导致抛出错误

我有这样的事情:

public string Amount { get; set; }

@Html.TextBoxFor(model => model.Amount, new { @class = "form-control", @placeholder = ModelMetadata.FromLambdaExpression(x => x.Amount, ViewData).Watermark })

$.extend($.fn.autoNumeric.defaults, {
            aSep: '@System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberGroupSeparator',
            aDec: '@System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator'
        });

$("#Amount").autoNumeric('init', { aSign: "$ " });

我已经搜索错误,发现this

但这对我没有帮助。

感谢您的帮助!

【问题讨论】:

  • 如果删除$ 符号后的空格会怎样?
  • 那行不通。同样的错误。

标签: c# jquery asp.net asp.net-mvc asp.net-mvc-5


【解决方案1】:

当我输入值时,在创建过程中输入为 $ 100,000.00 就是这样保存到数据库中。

但是,我已经更新了我的代码以在保存之前删除这些符号。

var amount = String.Join("", model.Amount.Split('$', ','));

所以如果输入$100,000.00,则保存为100000.00

这解决了这个问题。

【讨论】:

    猜你喜欢
    • 2015-10-02
    • 1970-01-01
    • 1970-01-01
    • 2014-03-26
    • 2014-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-29
    相关资源
    最近更新 更多