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

26 lines
653 B
JavaScript
Raw Normal View History

2017-03-16 15:29:07 +00:00
/**
* @file
2018-11-23 12:29:20 +00:00
* JavaScript behaviors for radio buttons.
2017-03-16 15:29:07 +00:00
*/
(function ($, Drupal) {
'use strict';
/**
2018-11-23 12:29:20 +00:00
* Adds HTML5 validation to required radios buttons.
2017-03-16 15:29:07 +00:00
*
* @type {Drupal~behavior}
2018-11-23 12:29:20 +00:00
*
* @see Issue #2856795: If radio buttons are required but not filled form is nevertheless submitted.
2017-03-16 15:29:07 +00:00
*/
2018-11-23 12:29:20 +00:00
Drupal.behaviors.webformRadiosRequired = {
2017-03-16 15:29:07 +00:00
attach: function (context) {
2018-11-23 12:29:20 +00:00
$('.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'});
});
2017-03-16 15:29:07 +00:00
}
};
})(jQuery, Drupal);