Skip to content

Instantly share code, notes, and snippets.

@mhz-tamb
Created July 5, 2017 13:24
Show Gist options
  • Save mhz-tamb/127ae92085141522389165ff2ad0c6b0 to your computer and use it in GitHub Desktop.
Save mhz-tamb/127ae92085141522389165ff2ad0c6b0 to your computer and use it in GitHub Desktop.
(function() {
'use strict';
function createElement(tagName, attributes) {
return Object.assign(document.createElement(tagName), attributes);
}
var privacyPolicyContainer = createElement('div', {className: 'form-control'});
privacyPolicyContainer.appendChild(createElement('input', {name: 'privacy-policy', type: 'checkbox', checked: true, required: true}));
privacyPolicyContainer.appendChild(createElement('label', {htmlFor: 'privacy-policy', innerHTML: 'Согласен на обработку моих персональных данных'}));
var excludeForms = [];
document.addEventListener('DOMContentLoaded', function() {
Array.prototype.forEach.call(document.forms, function(form) {
if (!excludeForms.includes(form.name)) {
form.insertBefore(privacyPolicyContainer, form.elements.lastChild);
}
});
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment