How to make a form field compulsory?

Topic summary

A user is seeking guidance on making a custom form field mandatory but hasn’t found clear instructions online. They’ve included screenshots of their form code for reference.

Solution provided:

  • Add the required attribute directly to input elements that need to be compulsory
  • This is a standard HTML feature with straightforward implementation
  • A Mozilla Developer Network documentation link was shared with examples demonstrating the required attribute syntax

The question appears resolved with this simple HTML-based approach, though no follow-up confirmation from the original poster is included.

Summarized with AI on November 9. AI used: claude-sonnet-4-5-20250929.

Hi all,

I’ve been trying to find a way to make my custom form have a new compulsory field. Can’t find anything online on how to do it!

Any help would be greatly appreciated!

Screenshot of form code:

Hi there,

You may just add the “required” attribute on the inputs you want to be compulsory. It’s simple, check out this doc to have a few examples.

For instance: