asp判断数据是否已经添加上,另外提示不能为空

来源:百度知道 编辑:UC知道 时间:2024/05/08 20:33:16
<form id="form1" name="form1" method="post" onSubmit="return chk();">
<p>公告内容:
<input name="notice" type="text" value="" size="80">
</p>
<p>文字颜色:
<%call titlecolor()%>
<input type="submit" name="Submit" value="提交">
<input type="reset" name="Submit2" value="重置">
</p>
</form>
这个表是用来在后台往数据库添加公告的,首先是加一个js语句不能叫公告是空的,另外添加成功后出现一个response.write输出一个提示成功的信息框 。。。。。在线等,,,,

1.判断是否为空
<script Language="JavaScript">
function chk() {
if (document.myform.notice.value=='') {
window.alert ("请输入用户名!");
myform.notice.focus();
return false
}return true
}
</script>
2.插入数据成功
response.write = "<script language=javascript>alert('插入数据成功!')</script>";

可能有地方要稍微调整下

function chk()
{
if(document.form1.notice.value=='')
{ alert('不能叫公告是空的');
return false;
}
return true;
}

添加成功:
response.write "<script>alert(""添加成功"");</script>";