js根據身份證號自動截取出生日期並填充/根據身份證號自動判斷性別案例


如下:

//根據身份證號自動判斷性別案例
function selectSex(obj) {
    var customercode = $(obj).val();
    if (customercode.length == 18) {
        var sexcode = customercode.substring(16, 17);
        var birth = customercode.substring(6, 10) + "-" + customercode.substring(10, 12) + "-" + customercode.substring(12, 14);
        //偶數為女性,奇數為男性
        if ((sexcode & 1) === 0) {
            $("#buyerSex").val("000");
        } else {
            $("#buyerSex").val("001");
        }
        $('#birth').datebox('setValue', birth);
    }
}

檢查身份證件有效期輸入是否正確

//檢查身份證件有效期輸入是否正確
function checkidefctdate()
{
    var idefctdate = $("#idefctdate").datetimebox("getValue");
    idefctdate = new Date(Date.parse(idefctdate.replace(/-/g, "/"))).valueOf();
    var nowDate = new Date().valueOf();
    if(idefctdate>nowDate){
        alert("證件有效期起始日期有誤,請修改");
        return false;
    }
    return true;
}

根據easyUI時間控件取值參考

var xxx= $("#loanbegindate").datebox('getValue');

end!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM