
$(document).ready(function() {
    $('#access').click(function() {
        a = 1;
        usermail = $('#email').attr("value");
        email  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
        if (usermail.match(email)) {
            $('#email').css('border','0px');
        } else {
            a += 1;
            $('#email').css('border','1px solid red');
            $("#email").animate({
                borderWidth: 2
            }, "slow");
            $("#email").animate({
                borderWidth: 1
            }, "slow")

        };
        userphone = $('#tel').attr("value");
        phone = /^\+?[0-9\-\(\)]{5,20}$/;
        if (userphone.match(phone)){
            $('#tel').css('border','0px');
        }
        else{
            a += 1;
            $('#tel').css('border','1px solid red');
            $("#tel").animate({
                borderWidth: 2
            }, "slow");
            $("#tel").animate({
                borderWidth: 1
            }, "slow");
        }
        username = $('#nam').attr("value");
        namere = /^[a-zA-ZА-Яа-я]{2,200}$/;
        if (username.match(namere)) {
            $('#nam').css('border','0px');
        } else {
            //window.alert()
            a += 1;
            $('#nam').css('border','1px solid red')
            $("#nam").animate({
                borderWidth: 2
            }, "slow");
            $("#nam").animate({
                borderWidth: 1
            }, "slow");
        };

        userlastname = $('#fam').attr("value");
        lastname = /^[a-zA-ZА-Яа-я]{2,200}$/;
        if (userlastname.match(lastname)) {
            $('#fam').css('border','0px');
        } else {
            a += 1;
            $('#fam').css('border','1px solid red');
            $("#fam").animate({
                borderWidth: 2
            }, "slow");
            $("#fam").animate({
                borderWidth: 1
            }, "slow");
        };
        if(a == 1){
            $('#rek').submit();
        }
    //
    });

    $('#access2').click(function() {
        a = 1;
        usermail = $('#email2').attr("value");
        email  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
        if (usermail.match(email)) {
            $('#email2').css('border','0px');
        } else {
            a += 1;
            $('#email2').css('border','1px solid red');
            $("#email2").animate({
                borderWidth: 2
            }, "slow");
            $("#email2").animate({
                borderWidth: 1
            }, "slow")

        };
        userphone = $('#tel2').attr("value");
        phone = /^\+?[0-9\-\(\)]{5,20}$/;
        if (userphone.match(phone)){
            $('#tel2').css('border','0px');
        }
        else{
            a += 1;
            $('#tel2').css('border','1px solid red');
            $("#tel2").animate({
                borderWidth: 2
            }, "slow");
            $("#tel2").animate({
                borderWidth: 1
            }, "slow");
        }
        username = $('#nam2').attr("value");
        name2 = /[a-zA-ZА-Яа-я]{2,200}/;
        if (username.match(name2)) {
            $('#nam2').css('border','0px');
        } else {
            a += 1;
            $('#nam2').css('border','1px solid red')
            $("#nam2").animate({
                borderWidth: 2
            }, "slow");
            $("#nam2").animate({
                borderWidth: 1
            }, "slow");
        };

        userlastname = $('#fam2').attr("value");
        lastname = /[a-zA-ZА-Яа-я]{2,200}/;
        if (userlastname.match(lastname)) {
            $('#fam2').css('border','0px');
        } else {
            a += 1;
            $('#fam2').css('border','1px solid red');
            $("#fam2").animate({
                borderWidth: 2
            }, "slow");
            $("#fam2").animate({
                borderWidth: 1
            }, "slow");
        };
        if(a == 1){
            $('#rek2').submit();
        }
    //

    });
});


