Move javascript to download file into form submission function to prevent download file with empty form