Check if form element exists before trying to reference it