$(document).ready(function() { /* Случайные слагаемые */ var sl1 = $('#sl1').text(randomInteger(0, 9)); var sl2 = $('#sl2').text(randomInteger(0, 9)); }); function upregData(){ if(checkValidatorPost()){ $.ajax({ type: "POST", contentType: "application/x-www-form-urlencoded; charset=utf-8", url: location.origin+"/php/registratAjx.php?nn="+randomInteger(1, 500)+"&contact_up=up", beforeSend: loadtimes('loading7_dark_green.gif'), cache: false, data: {clas: "no", fullname: $("#fullname").val(), email: $("#mail").val(), login: $("#login").val(), phones: $("#phones").val(), sl1: $("#sl1").text(), sl2: $("#sl2").text(), sum: $("#sum").val(), }, success: function(html){ $("#formaz").html(html); loadtimes(''); } }); }else{alert('NO');return false;}; } function checkValidatorPost(){ //if(!$('#yes:checked').val()){ return false;} var sumsl= $("#sl1").text()*1 + $("#sl2").text()*1; if($("#sum").val()!=sumsl){ return false;} return true; } function loadtimes(imgload){ document.getElementById("formaz").style.backgroundImage = "url('../images/"+imgload+"')"; } /* Генератор случайного числа */ function randomInteger(min, max) { var rand = min + Math.random() * (max + 1 - min); rand = Math.floor(rand); return rand; }