<SCRIPT>
function check(obj){
if(obj.value.length>=5){
document.getElementById('s1').innerHTML="only five";
}
}
</SCRIPT>
<BODY>
<TABLE>
USE:<input type="text" name="t1" id="t1" onpropertychange="check(this)">(5埵悢帤)
<span id="s1"><span>
</TABLE>
</BODY>

解决方案 »

  1.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-31j">
    <title>Insert title here</title>
    <script language="javascript" type="text/javascript">
    var messageBoxId = "messageBox";
    function getMsgElement() {
    var divMsg = document.getElementById(messageBoxId)
    if(!divMsg) {
    divMsg = document.createElement("div");
    divMsg.id = messageBoxId;
    }
    return divMsg
    }
    function showMsg(msg) {
    var divMsg = getMsgElement();
    divMsg.style.backgroundColor = "yellow";
    divMsg.innerHTML = msg;
    document.body.appendChild(divMsg);
    }
    </script>
    </head>
    <body>
    <input type="button" value="showMessage" onclick="showMsg('Message');" />
    </body>
    </html>
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-31j">
    <title>Insert title here</title>
    <script language="javascript">
    var messageBoxId = "messageBox";function showMsg() {
    var inputText = document.getElementById("inputText").value; if (inputText == "") {
    document.getElementById("errInfo").innerText = "Please input";
    }}
    </script>
    </head>
    <body>
    <span id="errInfo"></span>
    <input type="text" id="inputText"/>
    <input type="button" value="showMessage" onclick="showMsg();" />
    </body>
    </html>用SPAN实现的.