Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio
HTML

HTML5: Fix a Required Field Skipping Screen Reader Focus

- 28.11.26 - ErcanOPAK

🧩 Fix a Required Field Skipping Screen Reader Focus

When native HTML5 constraint validation finds an invalid required field on submit, the browser’s standard behavior is to move focus to it and report the problem – but a display:none element can never receive focus at all, by design. In a multi-step wizard where only the current step is shown and every other step is hidden purely with CSS (display:none) rather than the hidden attribute, a required field left behind in an earlier step is still part of the form and still gets validated on submit, but the browser’s attempt to focus it on failure is a silent no-op: no scroll, no focus ring, no screen reader announcement, and the form simply never submits.

🔎 The Problem

<form>
  <section data-step="1">...</section>
  <section data-step="2" style="display:none;">
    <label for="phone">Phone</label>
    <input id="phone" required>
  </section>
  <button type="submit">Submit</button>
</form>

<!-- Clicking Submit while step 2 is still display:none: -->
<!-- Chrome/Firefox/Safari constraint validation finds #phone invalid, -->
<!-- but a display:none element cannot receive focus, so focus() is a -->
<!-- silent no-op - no scroll, no focus ring, no screen reader -->
<!-- announcement, and the form simply does not submit -->

✅ Fix: Hide Steps With the hidden Attribute

  • Give every step section other than the currently visible one the hidden attribute (or disable its inputs) instead of relying on display:none alone – a hidden or disabled field is excluded from constraint validation entirely, so the browser never tries to focus it in the first place.
  • On each step change in the wizard’s own JavaScript, toggle required off on fields outside the active step and back on when that step becomes current, so validation only ever considers fields the user can currently see and interact with.
  • Test the multi-step flow with a screen reader, or at minimum with the keyboard alone watching for visible focus, after any change to which attribute hides a step – display:none and the hidden attribute look identical visually but behave completely differently for focus and validation.

🚨 Why This Is Dangerous

A submit button that silently does nothing, with no validation message, no focus movement, and nothing announced to assistive technology, is indistinguishable from a broken form – a screen reader user has no way to discover that the real problem is an invisible required field two steps back.

The browser’s native validation is only as accessible as the DOM state it’s validating against – a field it can’t focus is a field it also can’t tell anyone about.

— Frontend Architect

Related posts:

HTML: Use Lang Attribute for Accessibility and SEO

HTML: Use Lang Attribute for Accessibility and SEO

HTML: Using ARIA Roles for Better Accessibility

HTML: Using ARIA Roles for Better Accessibility

HTML5: Fix a Native input type=date Picker Displaying a Different Format Than What You're Actually S...

HTML5: Fix a Native input type=date Picker Displaying a Different Format Than What You're Actually S...

Views: 5
Found this useful? Share it
XLinkedInWhatsApp

Post navigation

The AI Prompt That Rewrites a Regex With Named Groups
WordPress: Fix a Redirect Loop After Forcing HTTPS in Settings

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Most Read

  1. 01How to make theater mode the default for Youtube 1,079 views
  2. 02How to add default value for Entity Framework migrations for DateTime and Bool 997 views
  3. 03Get the User Name and Domain Name from an Email Address in SQL 996 views
  4. 04Get the First and Last Word from a String or Sentence in SQL 873 views
  5. 05How to select distinct rows in a datatable in C# 868 views
  6. 06How to enable, disable and check if Service Broker is enabled on a database in SQL Server 671 views
  7. 07Add Constraint to SQL Table to ensure email contains @ 631 views
  8. 08Average of all values in a column that are not zero in SQL 584 views
  9. 09How to use Map Mode for Vertical Scroll Mode in Visual Studio 561 views
Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
Back to top
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com