【发布时间】:2016-05-02 18:01:23
【问题描述】:
我有这样的功能:
function whenEmpty(field) {
if (field.value == '') {
field.style.backgroundColor = "#ffcccc";
alert("Please fill the field.");
field.focus();
} else {
field.style.backgroundColor = "#ffff80";
}
}
在我想到这个想法之前(我想在按下 tab 键时调用这个函数。)我在属性 onblur 上调用了这个函数。
<tr>
<td>
<div class="required">
<label>Phone</label>
</div>
</td>
<td>
<form:input path="connote.destPhone" id="destPhone" htmlEscape="true" onfocus="this.select();" onmouseup="return false;" onblur="whenEmpty(this);" style="background-color:#ffff80" size="20" maxlength="50" tabindex="9" />
<form:errors path="connote.destPhone" cssClass="error" />
</td>
</tr>
但现在我只想在按 Tab 时调用该函数。
【问题讨论】:
标签: javascript enter onblur