jQuery:动态地检索自动化的值

发布于 2025-02-07 14:32:55 字数 874 浏览 1 评论 0原文

我有一组文本框,我在上面配置了一个自动化(此插件: httpps://github.com/autonumericer/autonumeric/autonumeric/自算):

$("input[name$='something']").autoNumeric('init', {aSep: '.', aDec: ',', aSign: ' €', vMax: '99999999999.9999'});

当我发布我的表格时,我想在文本框上重新格式化值:

function parseBeforeSubmit() {
    $("input[name$='something']").val(function(){
                                                    var myText = $(this)[0];
                                                    return myText.autoNumeric('get');
                                                });
}

显然我无法使其正常工作,我看到的是myText具有一个名为jquery3600005893939066666319538821的属性,其中包含自unumumeric,但似乎很奇怪,但这看起来很奇怪,这很奇怪我无法动态访问自动符号组件,而且似乎该自动符组件不包含未形式的数字值。

当然,我缺少一些东西,或者也许我使用了错误的方法?

I have a group of textbox on which I configured an autoNumeric (this plugin: https://github.com/autoNumeric/autoNumeric ):

$("input[name$='something']").autoNumeric('init', {aSep: '.', aDec: ',', aSign: ' €', vMax: '99999999999.9999'});

When I post my form I want to reformat the values on the textbox:

function parseBeforeSubmit() {
    $("input[name$='something']").val(function(){
                                                    var myText = $(this)[0];
                                                    return myText.autoNumeric('get');
                                                });
}

obviously I cant get it working, what I'm seeing is that myText has a property called jQuery36000058939066319538821 which contains autoNumeric, but it seems strange that I can't dynamically access the autoNumeric component and also it seems this autoNumeric component doesn't contains the unformatted numeric value.

Sure there's something I'm missing or maybe I used the wrong approach?

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

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

发布评论

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

评论(1

琉璃繁缕 2025-02-14 14:32:55

首先,您在示例中进行的调用是v1.9。 9%20documentation/“ rel =“ nofollow noreferrer”>弃用。
如果可以的话,您应该使用最新版本4.6.0,它更加用户友好,并且具有无jQuery依赖关系

如果您想在提交之前修改表单输入值,请查看特定的表单功能在官方文档中。

也许您需要FormNumericString()formArraynumericString()formjsonnumericsstring,取决于您的确切需求。

First and foremost, the call you are doing in your example are for v1.9.*, which is deprecated.
If you can, you should use the latest version 4.6.0, which is much more user friendly, and have no jQuery dependency.

If you want to modify the form input value before submitting, take a look at the specific form functions in the official documentation.

Perhaps you'll need formNumericString(), formArrayNumericString() or formJsonNumericString, depending of your exact need.

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