try{ c = 'campoX'; campo = document.getElementById(c);}catch(e){ alert('el campo '+c+' no existe!');}