Required field function not working and back button on first page is displayed