$(document).ready(function() { //initAutoForm("form.custom.gray"); $("input.inputphone").mask("+9(999)999-99-99",{placeholder:"_"}); $("input.phone-country-code").mask("+9",{completed:function(){$(this).parent().find(".phone-city-code").focus();splitPhones($(this).parent())},placeholder:"_"}); $("input.phone-city-code").mask("999",{completed:function(){$(this).parent().find(".phone-num").focus();splitPhones($(this).parent())}, placeholder:"_"}); $("input.phone-num").mask("9999999",{completed:function(){splitPhones($(this).parent())},placeholder:"_"}); $(".formcredit form").submit(function() { var flag = $("input[name='confirmed']").is(":checked"); if (!flag && $("input[name='confirmed']").length>0 ) { alert("Для оформления заявки необходимо согласиться с условиями и политикой конфиденциальности"); return false; } }) $(".carousel").jCarouselLite({ btnNext: ".all-banks .next", btnPrev: ".all-banks .prev", mouseWheel: true }); }) function updateModels(){ var brand = $("#marka option:selected").attr("code");; updateAutoForm(brand,false,false,true, $("form.custom.gray"),function(){ updateCustomSelect($("#model").get(0)); }); } function updateComplects(){ var brand = $("#marka option:selected").attr("code"); var model = $("#model option:selected").attr("code"); var autoName = $("#marka option:selected").text()+" "+ $("#model option:selected").text(); $("#auto_name").text(autoName); updateAutoForm(brand,model,false,false, $("form.custom.gray"),function(){ updateCustomSelect($("#complect").get(0)); }); } function splitPhones(compositephone) { var fullphone = true; var i=0; var splitter = "-"; var fullphonestr = ""; $(compositephone).find("input[type='text']").each(function(){ if (this.value.indexOf("_")>-1 || this.value.length==0 ) fullphone = false; if (i==0) fullphonestr+=this.value; else fullphonestr+=splitter+this.value; i++; }); if (fullphone) $(compositephone).find(".all-phone").val(fullphonestr); else $(compositephone).find(".all-phone").val(""); }