function mask(item){
item.forEach(function(input) {
let keyCode;
function mask(event) {
if(event.keyCode) keyCode = event.keyCode
const pos = this.selectionStart;
if (pos < 3) event.preventDefault();
const matrix = "+7 (___) ___-__-__";
let i = 0;
const def = matrix.replace(/\D/g, "");
const val = this.value.replace(/\D/g, "");
let new_value = matrix.replace(/[_\d]/g, function(a) {
return i < val.length ? val.charAt(i++) || def.charAt(i) : a
});
i = new_value.indexOf("_");
if (i != -1) {
if(i < 5) i = 3;
new_value = new_value.slice(0, i)
}
let reg = matrix.substr(0, this.value.length).replace(/_+/g,
function(a) {
return "\\d{1," + a.length + "}"
}).replace(/[+()]/g, "\\$&");
reg = new RegExp("^" + reg + "$");
if (!reg.test(this.value) || this.value.length < 5 || keyCode > 47 && keyCode < 58) this.value = new_value;
if (event.type == "blur" && this.value.length < 5) this.value = ""
}
input.addEventListener("input", mask, false);
input.addEventListener("focus", mask, false);
input.addEventListener("blur", mask, false);
input.addEventListener("keydown", mask, false)
});
}
<?php
$IBLOCK_ID = 14;
$arFilter = Array(
'IBLOCK_ID'=>$IBLOCK_ID,
'GLOBAL_ACTIVE'=>'Y');
$obSection = CIBlockSection::GetTreeList($arFilter);
while($arResult = $obSection->GetNext()){
echo $arResult["ID"] . $arResult["NAME"].'<br>';
$arOrder = Array("SORT"=>"ASC");
$arFilter = Array("SECTION_ID" => $arResult["ID"]);
$obElement = CIBlockElement::GetList($arOrder, $arFilter, false, false, Array());
while($ar_fields = $obElement->GetNext())
{
echo $ar_fields."<br>";
}
}
?>
"success": true, "challenge_ts": "2024-03-27T12:41:48Z", "hostname": "******.ru"