Pass required attribute for quickform fields through to form
Created by: mattwire
In quite a few cases the required attribute is not passed through to the actual form element via quickform. This happens in at least two situations:
- Billing address fields block.
- Any radio element in profiles.
"Required" attribute not passed through. Elements don't have "required" as a class on the .
"Required" attribute passed through. Elements (except radio) have "required" element as a class on the .
For radio elements we can't set the class required so we set the attribute "required=1" directly on the input:
<input required="1">. jQuery validate picks this up too and flags the field as required.
This library https://jqueryvalidation.org/ is part of CiviCRM core and is loaded automatically on various pages including contribution pages.
To test you can use the browser console and type (for a contribution page):
@seamuslee001 this is what @JoeMurray pinged you on previously :-)