autoNumeric.js在提交表单之前删除格式 [英] autoNumeric.js remove formatting before submitting form

查看:149
本文介绍了autoNumeric.js在提交表单之前删除格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery插件 AutoNumeric 但是当我提交表单时,我可以' t在 POST 之前删除字段上的格式。

I'm using the jQuery plugin AutoNumeric but when I submit a form, I can't remove the formatting on the fields before POST.

我试图使用 $( 'input')。autonumeric('destroy')(和其他方法),但它在文本字段上留下格式。

I tried to use $('input').autonumeric('destroy') (and other methods) but it leaves the formatting on the text fields.

怎么能我 POST 未格式化的数据到服务器?如何删除格式?在初始配置或其他地方是否有属性?

How can I POST the unformatted data to the server? How can I remove the formatting? Is there an attribute for it in the initial config, or somewhere else?

我不想将序列化表单数据发送到服务器(使用AJAX)。我想提交带有未格式化数据的表单,如普通的HTML操作。

I don't want to send the serialized form data to the server (with AJAX). I want to submit the form with the unformatted data like a normal HTML action.

推荐答案

我写了一个更好的,更为一般的黑客攻击为此在jQuery中

I wrote a better, somewhat more general hack for this in jQuery

$('form').submit(function(){
    var form = $(this);
    $('input').each(function(i){
        var self = $(this);
        try{
            var v = self.autoNumeric('get');
            self.autoNumeric('destroy');
            self.val(v);
        }catch(err){
            console.log("Not an autonumeric field: " + self.attr("name"));
        }
    });
    return true;
});

此代码清除带有错误处理的表单而不是autoNumeric值。

This code cleans form w/ error handling on not autoNumeric values.

这篇关于autoNumeric.js在提交表单之前删除格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆