Prevent accidental navigation when using form elements