jQuery:动态地检索自动化的值
我有一组文本框,我在上面配置了一个自动化(此插件: 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您在示例中进行的调用是
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()
orformJsonNumericString
, depending of your exact need.