diff --git a/includes/form.inc b/includes/form.inc
index 8f2ee26..482875c 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -1893,6 +1893,17 @@ function _form_builder_handle_input_element($form_id, &$element, &$form_state) {
     }
   }
 
+  // The #autofocus property should only be printed when #autofocus is true.
+  // If #autofocus is false, then we do not want to print the autofocus attribute
+  // at all. The reason for this is because the autofocus attribute is a boolean
+  // attribute. Explanation on boolean attributed: "The presence of a boolean
+  // attribute on an element represents the true value, and the absence of
+  // the attribute represents the false value." --
+  // http://www.w3.org/TR/html5/common-microsyntaxes.html#boolean-attribute
+  if (isset($element['#autofocus']) && $element['#autofocus'] === TRUE) {
+    $element['#attributes']['autofocus'] = 'autofocus';
+  }
+
   // With JavaScript or other easy hacking, input can be submitted even for
   // elements with #access=FALSE or #disabled=TRUE. For security, these must
   // not be processed. Forms that set #disabled=TRUE on an element do not
