I want to reformat the contents of an HTML form-field when submitting.
For example: The user enters "1.234,56
" (which is a valid format for numbers in this locale), but I want to submit the value "1234.56
" to the server.
I'd like to hear about other peoples experience with this. How do you do this?
My first thought is an onSubmit-event, which reformats the contents. But does anyone has any experience with an implementation on this?
Or maybe a better idea?
Javascript is ALWAYS available. If it's much easier with Dojo, I can use that.
And by the way: It's actually a bit more complex, since I also want to reformat on "blur" too. So the user enters "1234,56
" (input format). When focus changes, it should reformat to "1.234,56
" (display format). But the actual value sent to the server should be "1234.56
" (machine format).
Converting between input format and display format should be easy, but maybe all this can be combined in some clever way.
EDIT: This is not for a public website, so opinions about depending on Javascript and similar is not relevant.