想实现这样的效果,在一个文本框中输入内容,当时去焦点时,马上能判断输入是否为空,为空的话,马上在文本框下面显示提示信息“输入不可 <input name=haha onblur="if(this.value==''){alert('不能为空')}"> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <input name=haha onblur="if(this.value==''){aaaa.innerText='不能为空''}"><td id='aaaa'> <HTML><BODY ><table width="100%" > <tr> <td> <input name=haha onblur="if(this.value==''){aaaa.innerText='不能为空';}"></td><td id='aaaa'></td> </tr></table></BODY></HTML> <input name=haha onblur="if(this.value==''){this.value='不能为空'}"> <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> if(form1.userName.value == ""){ alert("用户名不能为空"); document.form1.userName.focus(); return false; } 关于一段js代码 看了大家提的问题的一点感想 Gmap2未定义??? JavaScript图片预加载代码.用起来不方便。那位能改的方便点 有清楚点的javascript权威指南吗?? JS如何实现SELECT左列表框值添加到右边列表框 window.open()在火狐里有模式窗体吗? 发现一个奇怪的现象 网页方面的问题 window.open()的中文问题。 正则表达式,怎么取一段html 网页一打开就让文本框的值 = 下拉框的值
<BODY >
<table width="100%" >
<tr>
<td> <input name=haha onblur="if(this.value==''){aaaa.innerText='不能为空';}">
</td>
<td id='aaaa'></td>
</tr>
</table>
</BODY>
</HTML>
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>
alert("用户名不能为空");
document.form1.userName.focus();
return false;
}