Form validation is not working correctly on show/hide conditions