Added code to validate required fields when the save button is clicked