<style>
.sendform {cursor:pointer}
.mainform .hide-input-mode {
opacity: 0;
height: 0;
max-height: 0;
min-height: 0;
pointer-events: none;
overflow: hidden;
position: absolute;
z-index: -10;
}
.slaveform .t-input-group_fr {
display: none;
}
.slaveform .t-input-group_fr.showcalc {
display: block;
}
</style>
<script>
$( document ).ready(function() {
let formID='';
//При клике на нашу кнопку
$('.sendform').click(function(e) {e.preventDefault();
formID = '#' + $(this).closest('.t-rec').attr('id');
let fullinput=true;
$('.t-input-group').removeClass('js-error-control-box');
$(formID).find('.js-tilda-rule[data-tilda-req="1"]').each(function() {
if($(this).val()==''){
$(this).closest('form').find('.t-submit').click();
fullinput=false;
return false;
};
});
if(fullinput){
$(formID).find('input[type="radio"][data-tilda-req="1"].js-tilda-rule').closest('.t-input-block').each(function() {
if(!$(this).find('input[type="radio"]').is(':checked')){
$(this).closest('form').find('.t-submit').click();
fullinput=false;
return false;
};
});
};
if(fullinput){
$(formID).find('input[type="checkbox"][data-tilda-req="1"].js-tilda-rule').each(function() {
if (!$(this).is(':checked')){
$(this).closest('form').find('.t-submit').click();
fullinput=false;
return false;
};
});
};
if(fullinput){
$(formID).find('.slaveform').each(function(){
$(this).find('.t-input-group').each(function(){
$(this).addClass('hide-input-mode');
$(this).clone().appendTo(formID+" .mainform .t-form__inputsbox");
if( $(this).hasClass('t-input-group_sb') ){
let selectName = $(this).find('select').attr('name');
$(formID+' .mainform select[name="'+selectName+'"]').val( $(formID+' .slaveform select[name="'+selectName+'"]').val() );
};
});
});
//Отправляем данные основной формы
setTimeout(function(){ $(formID).find('.mainform .t-submit').click() }, 500);
};
});
$(formID+' .mainform').delegate(".t-submit", "click", function(){
setTimeout(function(){
if ( $(formID+' .mainform .t-form').hasClass("js-send-form-success")){
$(formID+' .mainform .hide-input-mode').remove();
$('.slaveform .t-input-group_fr').addClass('showcalc');
$(formID+' .slaveform select option:first').prop('selected', true);
$(formID+' input').prop('checked', false);
let recID = formID.replace(/[^0-9]/g, '');t396_init(recID);
};
}, 1000);
});
$(document).on("keydown", ".t-form", function(event) {return event.key != "Enter";});
});
</script>