How do I override an exposed filter input type? I'm writing a module to change input HTML attributes with the next code:
use Drupal\Core\Form\FormStateInterface;

/**
 * Implements hook_form_alter().
 */
function custom_numeric_filter_form_alter(&amp;$form, FormStateInterface $form_state, $form_id) {
  $field = 'yourfieldname';
  if ($form_id == 'views_exposed_form' &amp;&amp; array_key_exists($field, $form)) {
    $form[$field]['#type'] = &quot;range&quot;;
    $form[$field]['#step'] = 5;
    $form[$field]['#size'] = 5;
    $form[$field]['#min'] = 10;
    $form[$field]['#max'] = 60;
  }
}

The problem is that the type gets overwritten back to number by something else.
I have Better Exposed Filters installed, maybe it gets rewritten there but why? And how can I make sure my module code has priority? With the help from NoSssweat I made sure it was executed after BEF and it didn't help.
Try in this way:
function seven_form_alter(&amp;$form, FormStateInterface $form_state, $form_id) {
  if (in_array($form_id, ['node_page_form', 'node_page_edit_form'])) {
    $form['field_number']['widget'][0]['value']['#type'] = 'range';
  }
}

I think this post will help you, check once - https://www.drupal.org/project/drupal/issues/2958499#comment-12558959