How to show Numeric keyboard while entering in textfield? I am creating a custom form field with text-field type. That will accept only numbers, so I want to display only numeric keyboard instead of alphanumeric keyboard. How can I achieve that?

I tried using Elements module but I don't want to use extra features of this module.So I am searching for code snippet. Is there any way to do it in a custom way?
First, create a module named html5_form_element. Then you need to set up the following

Implement hook_element_info() to tell Drupal about your element type:

/**
 * Implementation of hook_element_info()
 */
function html5_form_element_element_info()
{
  $types['number_input'] = array
  (
    '#input' =&gt; TRUE,
    '#theme' =&gt; 'number_input',
    '#theme_wrappers' =&gt; array('form_element'),
  );

  return $types;
}


Next implement hook_theme() to define the theme for your input type:

/**
 * Implementation of hook_theme()
 */
function html5_form_elements_theme()
{
  $theme = array
  (
    'number_input' =&gt; array
    (
      'render element' =&gt; 'element',
    ),
  );

  return $theme;
}


And finally, create the theme function that will theme your element:

function theme_number_input($variables)
{
  $element = $variables['element'];
  $element['#attributes']['type'] = 'number';
  element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength'));
  _form_set_class($element, array('form-number'));

  $extra = '';
  if ($element['#autocomplete_path'] &amp;&amp; !empty($element['#autocomplete_input']))
  {
    drupal_add_library('system', 'drupal.autocomplete');
    $element['#attributes']['class'][] = 'form-autocomplete';

    $attributes = array();
    $attributes['type'] = 'hidden';
    $attributes['id'] = $element['#autocomplete_input']['#id'];
    $attributes['value'] = $element['#autocomplete_input']['#url_value'];
    $attributes['disabled'] = 'disabled';
    $attributes['class'][] = 'autocomplete';
    $extra = '&lt;input' . drupal_attributes($attributes) . ' /&gt;';
  }

  $output = '&lt;input' . drupal_attributes($element['#attributes']) . ' /&gt;';

  return $output . $extra;
}


Clear your caches, and you can now use '#type' =&gt; 'number_input' in the Form API.