回 帖 发 新 帖 刷新版面

主题:javascript的type属性出错了。

我作了一个根据身份证号判断生日和性别的程序,主要的功能就是根据输入的身份证号判断,首先判断身份证号是否合法,如果合法,则自动填写下面的性别和生日选项,如果没有填写身份证或者身份证号不合法,则显示性别选项和生日选项供用户填写,但是运行后提示我“无法得到 type 属性。 不支持该命令。”而且value值也没有改变,大家帮我看看那里有问题,谢谢了。



<tr>
      <td class="text2">身份证号:</td>
      <td class="text2"><div class="div1"><input name="身份证号" id="IDcard" type="text" class="input" size="18" onBlur="checkIDcard()"></div><span id="checkIDcard">请认真填写,一般情况下不可修改。</span></td>
    </tr><tr>
      <td class="text2">生理性别:</td>
      <td class="text2"><select name="性别" id="sex" size="1" class="input1">
        <option value="男">男</option>
        <option value="女">女</option>
        <option value="" selected="selected">请选择</option>
      </select>
      除非有医院证明,否则不能更改</td>
    </tr><tr>
      <td class="text2">会员生日:</td>
      <td class="text2"><input name="生日" type="text" id="birthday" class="input" size="18"> 格式:1981-7-22</td>
    </tr>


<script langauge=javascript>
function Fill_bsvalue(str,date)
{        
        var IDcard = document.getElementById("name");
        var birthday = document.getElementById("birthday");
        var sex= document.getElementById("sex");
        var sel=document.getElementById("sex");
        sel.options.length=0;
        if (typeof(str)=="undefined")
        {
        sex.options[sex.options.length]=new Option("男","男");
        sex.options[sex.options.length]=new Option("女","女");
        var opobj =  new Option("请选择","");
        sex.add(opobj,0);
        sex.selectedIndex = 0;
        }else{
        sex.options[sex.options.length]=new Option(str,str);
        }
        if (typeof(date)=="undefined")
        {
[color=00FF00]        birthday.type="text";
        birthday.value="";
        IDcard.value="";
        }else{
        birthday.type="hidden";
        birthday.value=date[/color]        }
}

function checkIDcard(){
var IDcard = trim(document.getElementById("IDcard").value);
var cid = document.getElementById("checkIDcard");
var birthday = document.getElementById("birthday");
var sex= document.getElementById("sex");
if (IDcard!=""){
    if (/^(\d{15}|\d{17}[\d)xX])$/.test(IDcard))//测试身份证格式(是)
    {alert("formright");    
        if (!(/00/.test(IDcard.substr(2, 2)))||!(/00/.test(IDcard.substr(4, 2)))) //测试身份证号码(3-6)位是否为0(否)
        {alert("1-6");                                     //测试数据库数据(1-6)位地址码(没有数据)
        var getrs= new ActiveXObject("Microsoft.XMLHTTP");
        var num=IDcard.substr(0,6)
        getrs.open("post","getdateindb.asp?type=idcard&num="+num,false);
        getrs.send();
        alert("getdateindb.asp?type=idcard&num="+num);
        alert(getrs.readyState);
            alert(getrs.readyState);
            if (getrs.readyState == 4)
            {            
                switch (getrs.responseText)                       //测试数据库数据(1-6)位地址码
                {
                case "no":    
                alert("notindb");                                     //测试数据库数据(1-6)位地址码(没有数据)
                Fill_bsvalue();
                warning1(cid,IDcard_illegal);
                break;
                case "yes":    
                alert("indb");                                    //测试数据库数据(1-6)位地址码(有数据)    
                var d = new Date();
                var Year = d.getFullYear();
                    switch (IDcard.length)                        //分15位、18位测试
                    {
                    case 15:    
                    alert("15");                                //15位
                        if ((parseInt(IDcard.substr(6, 2))+1900)<(parseInt(Year)-70)||(parseInt(IDcard.substr(6, 2))+1900)>(parseInt(Year)-16))                                                        //测试年龄(过大或者过小)
                        {
                        Fill_bsvalue();
                        warning1(cid,IDcard_illegal);
                        }else{                                    //年龄正常
                            if (((parseInt(IDcard.substr(6, 2))+1900)%4==0)||((((parseInt(IDcard.substr(6, 2))+1900)%100==0)&&((parseInt(IDcard.substr(6, 2))+1900)%4==0))))                                    //测试是否闰年
                            {
                            var re=/^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/;
                            }else{
                            var re= /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/;
                            }
                            if (!re.test(IDcard))                //测试年月日是否合法
                            {
                            Fill_bsvalue();
                            warning1(cid,IDcard_illegal);
                            }else{
                            right(cid,OK);
                                if (parseInt(IDcard.substr(12, 3))%2==0)
                                {
                                var sex="女";
                                }else{
                                var sex="男";
                                }
                            var birthday=(parseInt(IDcard.substr(6, 2))+1900)+"-"+IDcard.substr(8, 2)+"-"+IDcard.substr(10, 2);
                            Fill_bsvalue(sex,birthday);
                            }
                        }
                    break;
                    case 18:
                    alert("18");
                        if (parseInt(IDcard.substr(6, 4))<(parseInt(Year)-70)||parseInt(IDcard.substr(6, 4))>(parseInt(Year)-16))
                        {
                        Fill_bsvalue();
                        warning1(cid,IDcard_illegal);
                        }else{
                            if ((parseInt(IDcard.substr(6, 4))%4==0)||((parseInt(IDcard.substr(6, 4))%100==0)&&(parseInt(IDcard.substr(6, 4))%4==0)))    
                            {
                            var re=/^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}[0-9Xx]$/;
                            }else{
                            var re= /^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}[0-9Xx]$/;
                            }
                            if (!(re.test(IDcard)))
                            {
                            Fill_bsvalue();
                            warning1(cid,IDcard_illegal);
                            }else{
                            var Y, JYM, S, M
                            S = (parseInt(IDcard.substr(0 , 1)) + parseInt(IDcard.substr(10 , 1))) * 7 + (parseInt(IDcard.substr( 1 , 1)) + parseInt(IDcard.substr( 11 , 1))) * 9 + (parseInt(IDcard.substr( 2 , 1)) + parseInt(IDcard.substr( 12 , 1))) * 10+ (parseInt(IDcard.substr( 3 , 1)) + parseInt(IDcard.substr( 13 , 1))) * 5 + (parseInt(IDcard.substr( 4 , 1)) + parseInt(IDcard.substr( 14 , 1))) * 8 + (parseInt(IDcard.substr( 5 , 1)) + parseInt(IDcard.substr( 15 , 1))) * 4 + (parseInt(IDcard.substr( 6 , 1)) + parseInt(IDcard.substr( 16 , 1))) * 2 + parseInt(IDcard.substr( 7 , 1)) * 1 + parseInt(IDcard.substr( 8 , 1)) * 6 + parseInt(IDcard.substr( 9 , 1)) * 3;
                              Y = S % 11;
                              JYM = "10X98765432";
                              M = JYM.substr(Y , 1);
                                  if (M == IDcard.substr(17 , 1))
                                { 
                                    if (parseInt(IDcard.substr(14, 3))%2==0)
                                    {
                                    var sex="女";
                                    }else{
                                    var sex="男";
                                    }
                                var birthday=IDcard.substr(6, 4)+"-"+IDcard.substr(10, 2)+"-"+IDcard.substr(12, 2);
                                Fill_bsvalue(sex,birthday);
                                right(cid,OK);
                                alert("rightcode");
                                }else{
                                warning1(cid,IDcard_illegal);    
                                Fill_bsvalue();
                                alert("wrongcode");
                                }
                            }
                        }
                    break;
                    }
                break;
                }
            }
        }else{                   //测试身份证号码(3-6)位是否为0(否)
        warning1(cid,IDcard_illegal);
        Fill_bsvalue();
        alert("3-6");
        }
    }else{                      //测试身份证格式(否)
    warning1(cid,IDcard_illegal);
    Fill_bsvalue();
    alert("form");
    }
}else{
cid.className="text2";
cid.innerHTML = '请认真填写,一般情况下不可修改。';
}
}

回复列表 (共1个回复)

沙发

找到问题了,input的type属性是只读的,不能改,现在我用readOnly属性来控制了。

我来回复

您尚未登录,请登录后再回复。点此登录或注册