main.js 1.11 KB
function addContacts () {
    const num = $('#contacts').find('.row');
    const userId = $('#contacts').data('userId');
    if(num.length >= 11) {
        return;
    }

    const html = $('#contacts').find('.row.hidden').html().replace(/{k}/g, num.length).replace(/disabled=""/g, '');

    $('#contacts').append('<div class="row cl">'+html+'</div>');
}


function relation (e) {
    if($(e).data('num') < 3) {
        const val = $(e).val();
        if ( $.inArray($(e).val(), ["0", "1"]) === -1) {
            layer.alert('头2个必须是直系亲属', function (index) {
                $(e).val(0);
                layer.close(index);
            });
        }
    }
}

function phone (e) {
    var phone = [];

    $('input[phone]').each(function () {
        if(e != this) {
            phone.push($(this).val());
        }
    });

    if( $.inArray($(e).val(), phone) !== -1) {
        layer.alert('联系方式不能相同');
        $(e).val('').focus();
    }
}

$('[name="deadLine"]').on('change', function () {
    if($(this).val() % 6) {
        layer.alert('期数只能是6的倍数');
        $(this).val('');
    }
})