摘要:js check fields (onblur) 多個
當onblur 檢查有一個以上時focus會互鎖, 形成提醒視窗會跳來跳去跳不完= =||
所以用個errBox來判別是那個物件呼叫,會先指定那個物件
<input name="Subject" value="" size=80 onblur="chcekall(this)" id="title" title="主旨">
<script language="JavaScript" type="text/javascript">
<!--
var errBox = null;
function checkall(obj) {
if (obj.value == "") {
if (!errBox || errBox == obj) {
errBox = obj;
alert(obj.title+"欄位不可為空值!");
obj.focus();
}
} else {
if (errBox == obj) errBox = null;
}
}
// -->
</script>