Add html5 input types using drupal form api I want to add HTML5 number type textfield in the form programmatically. I am building the form using hook_form().
I tried adding the code:-

$form['field_price']['#attributes']['type'] = 'number';


But it isnt working. 

Is there any other work around for the same?
Try Element module. it adds advance html5 elements to your form.

Similar question is asked here