<input name=haha onblur="if(this.value==''){alert('不能为空')}">

解决方案 »

  1.   

    <input name=haha onblur="if(this.value==''){aaaa.innerText='不能为空''}"><td id='aaaa'>
      

  2.   

    <HTML>
    <BODY >
    <table width="100%" >
      <tr>
        <td>&nbsp;<input name=haha onblur="if(this.value==''){aaaa.innerText='不能为空';}">
    </td>
    <td id='aaaa'></td>
      </tr>
    </table>
    </BODY>
    </HTML>
      

  3.   

    <input name=haha onblur="if(this.value==''){this.value='不能为空'}">
      

  4.   

    <div class="newsTable">* 新闻标题:<input type="text" class="inputN" name="News_Title" maxlength="50" onblur="IsEmptyOrNot(this,document.getElementById('Err_Msg_NewsTitle'))" /><span id="Err_Msg_NewsTitle" class="errMsg"> 请填写新闻标题!</span></div><script language="javascript">
    function IsEmptyOrNot(st,Msg)
    {
    if((st.type == 'text')||(st.type == 'textarea')||(st.type == 'file'))
    {
    if (st.value == '')
    {
    Msg.style.display = "inline";
    }
    else
    {
    Msg.style.display = "none";
    }
    }
    }
    </script>
      

  5.   

    if(form1.userName.value == ""){
        alert("用户名不能为空");
    document.form1.userName.focus();             
    return false;
      }