密码长度为6-10的判断 <input type="text" value="" id="mm"/> document.getElementById("mm").onblur=function(){ if(mm.value.length>=6&&mm.value.length<=10){ this.style.backgroundColor="green"; } else{ this.style.backgroundColor="red"; } };