<input type="text" id="subInputValue01" onChange="changeInputValue()"></input>
<input type="text" id="subInputValue02" onChange="changeInputValue()"></input>
//采用的是jQuery,不是JavaScript
function changeInputValue(){
var subInputValue01=$("#subInputValue01").val();
var subInputValue02=$("#subInputValue02").val();
if (subInputValue01!=""){ //第一个input框不为空,第二个无法输入
$("#subInputValue02").attr("disabled","disabled");
}else { //第一个input框为空,第二个移除disable
$("#subInputValue02").removeAttr("disabled")
}
if (subInputValue02!=""){
$("#subInputValue01").attr("disabled","disabled");
}else {
$("#subInputValue01").removeAttr("disabled")
}
}
//初始化
$(function () {
changeInputValue();
});