This repository has been archived on 2025-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
drupalcampbristol/web/modules/contrib/webform/js/webform.element.radios.js
2018-11-23 12:29:20 +00:00

26 lines
653 B
JavaScript

/**
* @file
* JavaScript behaviors for radio buttons.
*/
(function ($, Drupal) {
'use strict';
/**
* Adds HTML5 validation to required radios buttons.
*
* @type {Drupal~behavior}
*
* @see Issue #2856795: If radio buttons are required but not filled form is nevertheless submitted.
*/
Drupal.behaviors.webformRadiosRequired = {
attach: function (context) {
$('.js-webform-type-radios.required, .js-webform-type-webform-radios-other.required', context).each(function () {
$(this).find('input[type="radio"]').attr({'required': 'required', 'aria-required': 'true'});
});
}
};
})(jQuery, Drupal);