Automatically Add Asterisks to Required Form Fields

When building forms in Wappler, it’s easy to lose track of which fields are actually marked as required, especially once layouts get more complex columns, floating labels, Summernote/MediumEditor fields, etc.

To make life easier for both users and developers, you can automatically append a small red asterisk to any label that belongs to a required field. This means:

  • Users instantly see which fields must be completed

  • Developers can visually confirm that validation rules are correctly applied

  • No need to manually add asterisks to every label

  • Works across all Bootstrap form structures

Here’s the simplified CSS that handles everything:

/* Add asterisk to labels for required fields */
*:has(> [required])>.form-label::after,
*:has(> [required])>label::after {
    content: ' *';
    color: var(--bs-danger);
}
4 Likes