diff --git a/core/includes/form.inc b/core/includes/form.inc
index 038cfca..c6974c4 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -3951,8 +3951,8 @@ function theme_tel($variables) {
  * @param $variables
  *   An associative array containing:
  *   - element: An associative array containing the properties of the element.
- *     Properties used: #title, #value, #description, #size, #min, #max,
- *     #placeholder, #required, #attributes, #step.
+ *     Properties used: #title, #value, #description, #min, #max, #placeholder,
+ *     #required, #attributes, #step.
  *
  * @ingroup themeable
  */
@@ -3960,7 +3960,7 @@ function theme_number($variables) {
   $element = $variables['element'];
 
   $element['#attributes']['type'] = 'number';
-  element_set_attributes($element, array('id', 'name', 'value', 'size', 'step', 'min', 'max', 'maxlength', 'placeholder'));
+  element_set_attributes($element, array('id', 'name', 'value', 'step', 'min', 'max', 'placeholder'));
   _form_set_class($element, array('form-number'));
 
   $output = '<input' . drupal_attributes($element['#attributes']) . ' />';
@@ -3974,8 +3974,8 @@ function theme_number($variables) {
  * @param $variables
  *   An associative array containing:
  *   - element: An associative array containing the properties of the element.
- *     Properties used: #title, #value, #description, #size, #min, #max,
- *     #required, #attributes, #step.
+ *     Properties used: #title, #value, #description, #min, #max, #attributes,
+ *     #step.
  *
  * @ingroup themeable
  */
@@ -4032,6 +4032,26 @@ function form_validate_number(&$element, &$form_state) {
 }
 
 /**
+ * Form element validation handler for #type 'range'.
+ *
+ * Make sure range elements always have a value. Default to 0. The 'required'
+ * attribute is not allowed for range elements.
+ */
+function form_validate_range(&$element, &$form_state) {
+  if ($element['#value'] === '') {
+    $default_value = ($element['#min'] + $element['#max']) / 2;
+
+    // Round the default value to the step.
+    if (strtolower($element['#step']) != 'any') {
+      $steps = round($default_value / $element['#step']);
+      $default_value = $element['#step'] * $steps;
+    }
+
+    form_set_value($element, $default_value, $form_state);
+  }
+}
+
+/**
  * Returns HTML for a url form element.
  *
  * @param $variables
diff --git a/core/modules/field/modules/number/number.module b/core/modules/field/modules/number/number.module
index 1b9a300..b3f5615 100644
--- a/core/modules/field/modules/number/number.module
+++ b/core/modules/field/modules/number/number.module
@@ -324,11 +324,6 @@ function number_field_widget_form(&$form, &$form_state, $field, $instance, $lang
   $element += array(
     '#type' => 'number',
     '#default_value' => $value,
-    // Allow a slightly larger size that the field length to allow for some
-    // configurations where all characters won't fit in input field.
-    '#size' => $field['type'] == 'number_decimal' ? $field['settings']['precision'] + 4 : 12,
-    // Allow two extra characters for signed values and decimal separator.
-    '#maxlength' => $field['type'] == 'number_decimal' ? $field['settings']['precision'] + 2 : 10,
   );
 
   // Set the step for floating point and decimal numbers.
diff --git a/core/modules/field/modules/text/text.module b/core/modules/field/modules/text/text.module
index 985fa9b..dcf4d1e 100644
--- a/core/modules/field/modules/text/text.module
+++ b/core/modules/field/modules/text/text.module
@@ -225,7 +225,6 @@ function text_field_formatter_settings_form($field, $instance, $view_mode, $form
     $element['trim_length'] = array(
       '#title' => t('Trim length'),
       '#type' => 'number',
-      '#size' => 10,
       '#default_value' => $settings['trim_length'],
       '#min' => 1,
       '#required' => TRUE,
diff --git a/core/modules/field_ui/field_ui.api.php b/core/modules/field_ui/field_ui.api.php
index b6c8aee..ff85b5d 100644
--- a/core/modules/field_ui/field_ui.api.php
+++ b/core/modules/field_ui/field_ui.api.php
@@ -158,7 +158,6 @@ function hook_field_formatter_settings_form($field, $instance, $view_mode, $form
     $element['trim_length'] = array(
       '#title' => t('Length'),
       '#type' => 'number',
-      '#size' => 20,
       '#default_value' => $settings['trim_length'],
       '#min' => 1,
       '#required' => TRUE,
diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module
index 74c1823..1e0b7e1 100644
--- a/core/modules/filter/filter.module
+++ b/core/modules/filter/filter.module
@@ -1356,8 +1356,6 @@ function _filter_url_settings($form, &$form_state, $filter, $format, $defaults)
     '#type' => 'number',
     '#title' => t('Maximum link text length'),
     '#default_value' => $filter->settings['filter_url_length'],
-    '#size' => 5,
-    '#maxlength' => 4,
     '#min' => 1,
     '#field_suffix' => t('characters'),
     '#description' => t('URLs longer than this number of characters will be truncated to prevent long strings that break formatting. The link itself will be retained; just the text portion of the link will be truncated.'),
diff --git a/core/modules/image/image.admin.inc b/core/modules/image/image.admin.inc
index c6b1356..f31d98f 100644
--- a/core/modules/image/image.admin.inc
+++ b/core/modules/image/image.admin.inc
@@ -450,7 +450,6 @@ function image_resize_form($data) {
     '#default_value' => isset($data['width']) ? $data['width'] : '',
     '#field_suffix' => ' ' . t('pixels'),
     '#required' => TRUE,
-    '#size' => 10,
     '#min' => 1,
   );
   $form['height'] = array(
@@ -459,7 +458,6 @@ function image_resize_form($data) {
     '#default_value' => isset($data['height']) ? $data['height'] : '',
     '#field_suffix' => ' ' . t('pixels'),
     '#required' => TRUE,
-    '#size' => 10,
     '#min' => 1,
   );
   return $form;
@@ -547,8 +545,6 @@ function image_rotate_form($data) {
     '#description' => t('The number of degrees the image should be rotated. Positive numbers are clockwise, negative are counter-clockwise.'),
     '#field_suffix' => '&deg;',
     '#required' => TRUE,
-    '#size' => 6,
-    '#maxlength' => 4,
   );
   $form['bgcolor'] = array(
     '#type' => 'textfield',
diff --git a/core/modules/image/image.field.inc b/core/modules/image/image.field.inc
index 6138b53..5f5d1a9 100644
--- a/core/modules/image/image.field.inc
+++ b/core/modules/image/image.field.inc
@@ -90,8 +90,6 @@ function image_field_instance_settings_form($field, $instance) {
     '#title' => t('Maximum width'),
     '#title_display' => 'invisible',
     '#default_value' => $max_resolution[0],
-    '#size' => 5,
-    '#maxlength' => 5,
     '#min' => 1,
     '#field_suffix' => ' x ',
   );
@@ -100,8 +98,6 @@ function image_field_instance_settings_form($field, $instance) {
     '#title' => t('Maximum height'),
     '#title_display' => 'invisible',
     '#default_value' => $max_resolution[1],
-    '#size' => 5,
-    '#maxlength' => 5,
     '#min' => 1,
     '#field_suffix' => ' ' . t('pixels'),
   );
@@ -121,8 +117,6 @@ function image_field_instance_settings_form($field, $instance) {
     '#title' => t('Minimum width'),
     '#title_display' => 'invisible',
     '#default_value' => $min_resolution[0],
-    '#size' => 5,
-    '#maxlength' => 5,
     '#min' => 1,
     '#field_suffix' => ' x ',
   );
@@ -131,8 +125,6 @@ function image_field_instance_settings_form($field, $instance) {
     '#title' => t('Minimum height'),
     '#title_display' => 'invisible',
     '#default_value' => $min_resolution[1],
-    '#size' => 5,
-    '#maxlength' => 5,
     '#min' => 1,
     '#field_suffix' => ' ' . t('pixels'),
   );
diff --git a/core/modules/poll/poll.module b/core/modules/poll/poll.module
index c801579..420b3c6 100644
--- a/core/modules/poll/poll.module
+++ b/core/modules/poll/poll.module
@@ -387,8 +387,6 @@ function _poll_choice_form($key, $chid = NULL, $value = '', $votes = 0, $weight
     '#title' => $value !== '' ? t('Vote count for choice @label', array('@label' => $value)) : t('Vote count for new choice'),
     '#title_display' => 'invisible',
     '#default_value' => $votes,
-    '#size' => 5,
-    '#maxlength' => 7,
     '#min' => 0,
     '#parents' => array('choice', $key, 'chvotes'),
     '#access' => user_access('administer nodes'),
diff --git a/core/modules/search/search.admin.inc b/core/modules/search/search.admin.inc
index 5355c6a..bef8fd9 100644
--- a/core/modules/search/search.admin.inc
+++ b/core/modules/search/search.admin.inc
@@ -93,9 +93,8 @@ function search_admin_settings($form) {
     '#type' => 'number',
     '#title' => t('Minimum word length to index'),
     '#default_value' => variable_get('minimum_word_size', 3),
-    '#size' => 5,
-    '#maxlength' => 3,
     '#min' => 1,
+    '#max' => 1000,
     '#description' => t('The number of characters a word has to be to be indexed. A lower setting means better search result ranking, but also a larger database. Each search query must contain at least one keyword that is this size (or longer).')
   );
   $form['indexing_settings']['overlap_cjk'] = array(
diff --git a/core/modules/system/image.gd.inc b/core/modules/system/image.gd.inc
index 4dd5ea1..b8dd822 100644
--- a/core/modules/system/image.gd.inc
+++ b/core/modules/system/image.gd.inc
@@ -23,8 +23,6 @@ function image_gd_settings() {
       '#type' => 'number',
       '#title' => t('JPEG quality'),
       '#description' => t('Define the image quality for JPEG manipulations. Ranges from 0 to 100. Higher values mean better image quality but bigger files.'),
-      '#size' => 10,
-      '#maxlength' => 3,
       '#min' => 0,
       '#max' => 100,
       '#default_value' => variable_get('image_jpeg_quality', 75),
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 200a335..2654509 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -405,9 +405,7 @@ function system_element_info() {
   );
   $types['number'] = array(
     '#input' => TRUE,
-    '#size' => 30,
     '#step' => 1,
-    '#maxlength' => 128,
     '#process' => array('ajax_process_form'),
     '#element_validate' => array('form_validate_number'),
     '#theme' => 'number',
@@ -415,13 +413,11 @@ function system_element_info() {
   );
   $types['range'] = array(
     '#input' => TRUE,
-    '#size' => 30,
     '#step' => 1,
     '#min' => 0,
     '#max' => 100,
-    '#maxlength' => 128,
     '#process' => array('ajax_process_form'),
-    '#element_validate' => array('form_validate_number'),
+    '#element_validate' => array('form_validate_range', 'form_validate_number'),
     '#theme' => 'range',
     '#theme_wrappers' => array('form_element'),
   );
diff --git a/core/modules/user/user.admin.inc b/core/modules/user/user.admin.inc
index 8de4fb9..c65883a 100644
--- a/core/modules/user/user.admin.inc
+++ b/core/modules/user/user.admin.inc
@@ -404,8 +404,6 @@ function user_admin_settings() {
     '#type' => 'number',
     '#title' => t('Picture upload file size'),
     '#default_value' => variable_get('user_picture_file_size', '30'),
-    '#size' => 10,
-    '#maxlength' => 10,
     '#min' => 0,
     '#field_suffix' => ' ' . t('KB'),
     '#description' => t('Maximum allowed file size for uploaded pictures. Upload size is normally limited only by the PHP maximum post and file upload settings, and images are automatically scaled down to the dimensions specified above.'),
