amsul/pickadate.js — pull request #18 by peterjmag (2012-11-21 22:08:35+00:00)
Title: Add an option to reformat the date value on submit

Here's my first shot at your "alternate value sent to server" todo item. With this change, if a date picker element has a parent form, we bind an event to that form to reformat the date field's value to the format defined in `SETTINGS.format_submit` before submitting the form. You can also disable the behavior by setting `format_submit` to `false`.

I'm still tweaking it a bit, because there are a couple of minor issues with this approach:

- You can see the field value change for a moment before the new page loads. Also, when you navigate back to that page, the value remains reformatted (though that may or may not be a problem).
- I haven't tested it much with AJAXy forms. I want to make sure it doesn't cause problems with other submit event handlers.
- It might throw an error on non-`` elements when it tries to find a parent form. I still need to play around with it, but it looks like I can solve this by using `P.$element.closest('form')` instead of `P._element.form`: http://stackoverflow.com/a/991371/349353