condensed and improved code repeated for each control type, added 'tel' control type