Required field function not working