Required field not working properly