Course Overview
Locked video preview

Paid video

Please purchase the course to watch.

Modern hypermedia

Inline validation new article

Here is a summary of the video transcript:

  • Goal: Inline Form Validation
    The video introduces real-time validation for a new article form to provide instant feedback while typing. This improves user experience by avoiding unnecessary full form submissions.

  • Frontend Refactoring and Event Handling
    The form is refactored into reusable components, and keydown events are debounced to trigger validation requests. Event bubbling is leveraged to handle input changes at the form level rather than per field.

  • Validation Endpoint and Backend Setup
    A new validation endpoint is created to process form data asynchronously. The backend reuses existing validation logic and returns updated form elements with validation errors using server-sent events (SSE).

  • Dynamic DOM Patching with DataStar
    DataStar is used to patch specific DOM elements based on IDs or selectors. Proper element targeting and patch modes ensure that only intended parts of the form are updated.

  • Rich Text Editor Reinitialization
    The EasyMDE editor breaks after DOM replacement, so it is reinitialized via a globally exposed JavaScript function. Change events are manually dispatched to keep the editor content synchronized with form state.

  • Switch to Data Binding and JSON Payloads
    The form transitions from traditional form submissions to DataStar signals with data-bind attributes. The backend adapts to JSON input, enabling more precise state-driven validation.

  • Conditional Validation Rules
    Validation logic is duplicated at the payload level to allow optional fields during typing. This prevents premature validation errors for empty fields while maintaining stricter validation during final submission.

  • Create Article Flow with SSE Redirects
    The create controller integrates SSE-based validation and conditional redirects. On validation failure, errors are returned and displayed; on success, the user is redirected to the edit page with appropriate feedback.

  • Next Steps
    The same real-time validation and SSE-driven updates will be applied to the edit article page to maintain consistency across the application.