Required field function is not working