日期:2014-05-17  浏览次数:21183 次

正则表达式验证必须小于12位数字?
<TD bgColor=#61cefc colSpan=4 align=middle>企业组织机构代码</TD>
<TD>
<Select Type="text" name="select_11" id="select_11" Style="WIDTH: 140px" >
<Option selected value="-1" name="select_0_0" id="select_0_0">请选择</Option>
<Option value="未办理" name="select_0_1" id="select_0_1">未办理</Option>
<Option value="已办理" name="select_0_2" id="select_0_2">已办理
</Option>
</Select>
<input type="text" value="" "style="display:none"> 
</TD>
如何当select里选择已办理时 显示隐藏的文本框 并输入企业组织机构代码,选择未办理时 隐藏文本框的值为未办理

------解决方案--------------------
JScript code

function banli(){
    var select_11 = document.getElementById("select_11");
    var test = document.getElementById("test");
    if(select_11.value=="bbb"){
        test.style.display = "block";
        test.value = "";
    }else if(select_11.value=="aaa"){
        test.style.display = "block";
        test.value = select_11.value;
        test.readonly = "readonly";
    }else{
        test.style.display = "none";
    }
}

------解决方案--------------------
验证小于12的js,用正则了,你稍微改一下就能用了
JScript code

function isURL(strURL){
    var reg2 = /^([0-9]{1,12})?$/g
       if (reg2.test(strURL)){
        return true;  
       }else{
           return false;  
       }
}
function check(){
   var myurl = document.getElementById("myurl").value;
   if(isURL(myurl)){
    alert(myurl+"\nright");
   }else{
    alert(myurl+"\nwrong");
   }
}
<input type="text" id="myurl" value="55555"><a href="javascript:check()">test</a>