Required validation check not working within the form