How can I make a phone number, or other address field, required?

By default, all address fields are optional. Commerce ships with a Basic Address Validation module that allows you to mark which fields are required. It's strongly encouraged to enable this module on all shops, unless you have another module in place that validates the address exists.

To change the required fields with the Basic Address Validation module, navigate to Extras > Commerce > Modules and find Basic Address Validation in the list. Click its name, make sure the module is enabled, and enter a comma-separated list of fields in the "Required Fields" option. The full list of possible fields is available in the documentation. The module makes sure the fields have a value, and for email and country fields it does some additional checking to make sure it's a valid value.

While the Basic Address Validation module is processed server-side, you can also consider using custom templates to add client-side validation (e.g. HTML5 required attribute or a JavaScript validation script).

Still need help? Send us an email Send us an email