问题描述
我正在使用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格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!