如果文本域为空的时候按验证文本域的边框会变红色,按第一个字符时,边框才变为原来的颜色。
<
script
>
...

function $(objID) ...{
return document.getElementById(objID)
}

function yz()...{
var oText=$("word");

if (oText.value=="")...{
oText.focus();
oText.style.border="1px solid #FF0000";

oText.onkeypress = function()...{oText.style.border="1px solid #CCC"};
return false;
}
}
</
script
>
<
textarea
cols
="54"
rows
="8"
name
="word"
></
textarea
>
<
input
type
="button"
onclick
="yz()"
value
="验证"
/>
HTML 代码:




















