Refactored JS to keep upload button enabled when using back button