日期:2014-05-17 浏览次数:21183 次
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,用正则了,你稍微改一下就能用了
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>