Accessible Coding

Form Data Loss Prevention

Nothing frustrates users more than filling out a form only to lose their work. In this chapter, you’ll learn how to keep user input safe and accessible, even when errors happen or a page reloads. You’ll learn best practices for preserving data across sessions, handling validation errors without clearing fields, and meeting WCAG requirements for error identification and recovery. By the end, you’ll know how to build forms that protect users’ time, reduce abandonment, and create a smoother experience for everyone.

data loss collage

What is Data Loss Prevention (DLP), and Why Is It Important?

Data loss prevention is the set of strategies, tools, and practices designed to ensure that sensitive or critical information is not lost, corrupted, or accessed by unauthorized users. In the context of digital forms and web applications, DLP focuses on preventing users from losing the data they’ve entered, like form fields or application inputs, due to session timeouts, page reloads, errors, or system crashes.

Key points for understanding DLP in forms:

Preservation of user input

Ensures data stays intact even if an error occurs or the session expires.

User experience protection

Reduces frustration and prevents users from having to re-enter information.

Accessibility compliance

Helps meet standards like WCAG by ensuring that error recovery doesn’t erase content.

The primary purpose of preventing data loss in digital forms is to ensure that forms save and maintain data when users are timed out from an authenticated space. This means that if a user's session expires, they should be able to continue their activity without losing the information they have already entered.

How Does Data Loss Prevention Impact Accessibility?

Preventing data loss is crucial for ensuring that everyone can effectively use digital content and tools without frustration.

For example, people with certain cognitive or motor disabilities may take longer to complete tasks. If their session times out and they lose all entered data, it creates a significant barrier and forces them to restart, potentially leading to frustration and an inability to complete the task.

Additionally, when forms, especially critical ones like login, signup, or checkout forms, are inaccessible due to data loss, users can be completely blocked from accessing a site or purchasing products. The requirement to re-authenticate without data loss is considered an accessibility best practice, even being a Level AAA success criterion in WCAG.

Quiz Yourself

What is data loss prevention?

@

Not Quite!

Hint: Think about what happens when you fill out a form and something interrupts your session. What strategies help make sure they don't lose the information you've already entered?

Quiz Yourself

How is DLP related to accessibility?

@

Not Quite!

Hint: Think broad. How does preventing data loss benefit users specifically?

Quiz Yourself

What is the primary goal of preventing data loss in forms?

@

Not Quite!

Hint: Think about a screen reader user's experience. What would make it easier for them in the event they have to resubmit a form?

What WCAG Success Criteria are Relevant for Preventing Data Loss?

The Web Content Accessibility Guidelines (WCAG) include a specific success criterion directly addressing the prevention of data loss:

WCAG Success Criterion 2.2.5 Re-authenticating: This criterion states that if an authenticated session expires, the user must be able to continue their activity without losing data after re-authenticating. It is noted as a Level AAA success criterion, highlighting its importance as a best practice for accessibility.

How Do I Maximize Accessibility When I Code Forms?

To prevent data loss, developers should implement mechanisms to save and maintain form data even when a user's authenticated session expires.

Similarly, it is vital to allow for timeout extensions for users who may take longer to complete tasks, such as those with cognitive or motor disabilities.

When a timeout is about to occur, ensure that cursor focus is driven to the timeout option so users can effectively choose to extend their session or log out, thus preventing abrupt data loss.

How Do I Test the Accessibility of Forms?

To ensure data loss prevention is effectively implemented, consider the following testing methods, particularly for forms and authenticated sessions:

Keyboard Navigation

Test that all form fields can be focused, filled out, or selected using only the keyboard. Ensure users can navigate and interact with all elements, including any timeout extension options.

Screen Reader Testing

  • Verify that screen readers announce labels and instructions for all form fields, ensuring users understand what information is required.

  • If a session timeout warning appears, ensure the screen reader immediately announces its presence and the shift of focus to the relevant interactive elements (e.g., extend session button).

  • Test the re-authentication process to confirm that previously entered data is retained after re-authenticating.

Simulate Session Timeouts

Actively test scenarios where authenticated sessions expire to confirm that data is indeed saved and retained upon re-authentication, allowing the user to continue their activity without interruption or loss of progress.

Quiz Yourself

Which WCAG success criterion specifically addresses allowing users to continue activity without data loss after re-authenticating?

@

Not Quite!

Hint: Look for the criteria that focuses on preserving user input and preventing frustration when a session times out.

Quiz Yourself

Why is preventing data loss particularly important for users with cognitive or motor disabilities?

@

Not Quite!

Hint: Think about how cognitive disabilities impact a person's ability to process information.

Keep Learning

Move to the next chapter: Timeouts.

Frequently Asked Questions