How can I remove AutoNumeric formatting before submitting form?

后端 未结 11 2976
栀梦
栀梦 2021-02-19 05:26

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

I tried to use $(\'input\

11条回答
  •  爱一瞬间的悲伤
    2021-02-19 06:19

    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;
    });
    

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

提交回复
热议问题