собрал две формы
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
inputPhone('.form-input__phone', '.form-input-phone__icon', '.form-input-phone__code', '.form-input-phone__input', '.form-input-phone__list', '.form-input-phone-list__item', '.form-input-phone-list-item__icon', '.form-input-phone-list-item__code');
|
||||
|
||||
function inputPhone(main, mainFlag, mainCode, input, list, selects, selectIcon, selectCode) {
|
||||
@@ -22,7 +23,8 @@ function inputPhone(main, mainFlag, mainCode, input, list, selects, selectIcon,
|
||||
let newIcon = e.querySelector(selectIcon),
|
||||
newCode = e.querySelector(selectCode);
|
||||
|
||||
e.onclick = function () {
|
||||
e.onclick = function (event) {
|
||||
event.preventDefault();
|
||||
thisMainFlag.style.cssText = `background-image:url("${newIcon.src}");`;
|
||||
thisMainCode.textContent = newCode.textContent;
|
||||
|
||||
@@ -36,7 +38,9 @@ function inputPhone(main, mainFlag, mainCode, input, list, selects, selectIcon,
|
||||
})
|
||||
}
|
||||
|
||||
checkPhone('.form-input-phone__input');
|
||||
if (document.querySelector('.form-input-phone__input')) {
|
||||
checkPhone('.form-input-phone__input');
|
||||
}
|
||||
|
||||
function checkPhone(input) {
|
||||
document.querySelector(input).addEventListener('input', function(event) {
|
||||
@@ -69,7 +73,9 @@ function inputTwo(inputTwo, button, oval, input) {
|
||||
thisMain = e;
|
||||
|
||||
thisButtons.forEach(button => {
|
||||
button.onclick = function () {
|
||||
button.onclick = function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
let newLeft = button.clientWidth;
|
||||
let newValue = button.textContent;
|
||||
|
||||
@@ -99,7 +105,9 @@ function inputRadio(main ,item, textClass, input) {
|
||||
items.forEach(radio => {
|
||||
let thisText = radio.querySelector(textClass).textContent;
|
||||
|
||||
radio.onclick = function () {
|
||||
radio.onclick = function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
if (inputRadio.querySelector(`${item}.active`)) {
|
||||
inputRadio.querySelector(`${item}.active`).classList.remove('active');
|
||||
}
|
||||
@@ -127,7 +135,8 @@ function listInputRadio(main ,item, textClass, input, content, block) {
|
||||
}
|
||||
|
||||
items.forEach(item => {
|
||||
item.onclick = function () {
|
||||
item.onclick = function (event) {
|
||||
event.preventDefault();
|
||||
let newText = item.querySelector(textClass).textContent;
|
||||
|
||||
thisInput.value = newText;
|
||||
@@ -143,4 +152,4 @@ function listInputRadio(main ,item, textClass, input, content, block) {
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user