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').autonumeric('destroy')
(and other methods) but it leaves the formatting on the text fields.
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?
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.
You could use the getArray method (http://www.decorplanit.com/plugin/#getArrayAnchor).
$.post("myScript.php", $('#mainFormData').autoNumeric('getArray'));
I came up with this, seems like the cleanest way. I know it's a pretty old thread but it's the first Google match, so i'll leave it here for future
I wrote a better, somewhat more general hack for this in jQuery
This code cleans form w/ error handling on not autoNumeric values.
Use the
get
method.This will always submit
"15"
. Now get creative :)Mirrored raw value:
The in
submit.php
ignore the value formy_field_formatted
and usemy_field
instead.With newer versions you can use the option:
Inside data callback you must call getString method like below: