62,074
社区成员
发帖
与我相关
我的任务
分享
function trim(txt)
{
return txt.replace(/(^\s+)|(\s+$)/g, "");
}
document.forms[0].onsubmit=function()
{
var txt = document.getElementById("TextBox1").value;
txt=trim(txt);
if(txt=="")
{
alert("不能为空!");
return false;
}
return true;
}
<script type="text/javascript">
document.forms[0].onsubmit=function()
{
if(document.getElementById("TextBox1").value=="")
{
alert("不能为空!");
return false;
}
return true;
}
</script>