Add type='tel' attribute to webform field I want to add the html5 tel attribute to a particular field in my webform form in order to prompt mobile devices to display the appropriate keyboard.

I was trying this:

function my_module_form_alter(&amp;$form, $form_state, $form_id) {

    /* add html5 phone type for phones and smarter devices to use */
    /* usage: just include the word 'phone' in the field title and have the field of type 'textfield' */

    foreach ($form['submitted'] as &amp;$field){
        if (is_array($field) &amp;&amp; isset($field['#title']) &amp;&amp; stristr(strtolower($field['#title']), 'phone') &amp;&amp; isset($field['#type']) &amp;&amp; ($field['#type'] == 'textfield')){
            $field['#attributes']['type'] = 'tel';
        }
    }
}


but the attribute doesn't get applied and the resulting field has the type of "text"

I suspect there may be a hook for webforms that will let me adjust the output, I just can't find it.
Drupal 7 core field doesn't support HTML 5 form elements.  

You should try the Elements module to do that.


  This module intends to become a repository for advanced form elements. Supports HTML 5 standards like: (url, email, search, tel, number, range)