<!-- Код для запоминания введённых данных из любой обычной формы -->
<!-- https://roman-kosov.ru/tilda-forms-autocomplete -->
<script>
$(document).ready(function () {
setTimeout(function () {
$('.js-form-proccess').each(function (i, form) {
var $form = $(form);
var formSuccessCallback = $form.data('success-callback');
var cachedCallback = window[formSuccessCallback];
window[formSuccessCallback] = (function () {
return function () {
$($form.serializeArray()).each(function (i, el) {
if (el.name.indexOf('form-spec-') === -1 && (el.name.indexOf('tildaspec-') === -1 || el.name === 'tildaspec-phone-part[]') && el.name.indexOf('formservices') === -1) {
if (el.value !== '') {
localStorage.setItem(el.name, el.value);
}
}
});
return cachedCallback($form);
};
})();
});
$.each(window.localStorage, function (name, value) {
if (name === 'tildaspec-phone-part[]') {
setTimeout(function () {
$('[name="' + name + '"]').val(value);
$('.t-input-phonemask').trigger('input');
}, 1000);
}
$('[name="' + name + '"]:not([type="radio"])').val(value);
try {
$('[type="radio"][value="' + value + '"]').prop('checked', true);
} catch (e) { /**/ }
});
}, 1000);
});
</script>