Skip to content

Fix form validation visuals in all forms. #124

@rtrbt

Description

@rtrbt

https://getbootstrap.com/docs/4.5/components/forms/#how-it-works
says

Bootstrap scopes the :invalid and :valid styles to parent .was-validated class, usually applied to the <form>. Otherwise, any required field without a value shows up as invalid on page load. This way, you may choose when to activate them (typically after form submission is attempted).
To reset the appearance of the form (for instance, in the case of dynamic form submissions using AJAX), remove the .was-validated class from the <form> again after submission.

The correct way to do this is

if (!this.checkValidity()) {
    this.classList.add('was-validated');
    return;
 } else {
    this.classList.remove('was-validated');
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions