internetee-registry/app/assets/javascripts/text_field_trimmer.js
Artur Beljajev 02f9e99428 Support IE11
Previously `let of` loop was used, which isn't supported in IE11.

It seems it just fails when there is some JS syntax error
(doesn't matter where exactly) and dataType: 'json' has no effect.

Closes #982
2018-10-27 16:18:29 +03:00

17 lines
508 B
JavaScript

(function () {
function trimTextFields() {
let selector = 'input[type=text], input[type=search], input[type=email], textarea';
let textFields = document.querySelectorAll(selector);
let changeListener = function () {
this.value = this.value.trim();
};
textFields.forEach(
function (field, currentIndex, listObj) {
field.addEventListener('change', changeListener);
}
);
}
trimTextFields();
})();