focus 问题(在线等)
三个textbox,输入完第一个鼠标移动到第二个textbox时,就没有focus了,但是如果我输入完第一个,点击页面任意空白处,focus就会出现。
<tr>
<th> Apple </th>
<td> $0.69 </td>
<td> <input type = "text" name = "apple" id = "apple" value = "0"
size ="2" onchange= "chkQty(id);computeCost();"/> </td>
</tr>
<tr>
<th> Orange </th>
<td> $0.59 </td>
<td> <input type = "text" name = "orange" id = "orange" value = "0"
size = "2" onchange= "chkQty(id);computeCost();"/> </td>
</tr>
<tr>
<th> Banana </th>
<td> $0.39 </td>
<td> <input type = "text" name = "banana" id = "banana" value = "0"
size = "2" onchange= "chkQty(id);computeCost();"/></td>
</tr>
</table>
下面是我的chkQty function:
function chkQty(id) {
var myQty = document.getElementById(id);
var pos = myQty.value.search(/\d+/);
if (pos != 0) {
alert("The quanity you entered (" + myQty.value +
") is invalid. \n" +
"Please enter digits for quantity");
myQty.focus();
myQty.select();
return false;
} else
return true;
}
大家帮帮忙了
多谢