Custom JavaScript and HTML is causing fields to jumble on submit