用ASP做网页,当用户名或者密码为空的时候,单击确定按钮,弹出不能为空的对话框,这个函数怎么写啊

来源:百度知道 编辑:UC知道 时间:2024/06/07 01:52:27

先在按钮做个单击事件 onClick="check()"

<script language="vbscript">
sub check()
if document.all.username.value="" then
alert("用户名不能为空")
document.all.username.focus()
window.event.returnvalue=false
exit sub
end if
end sub

</script>

测试通过的代码:

<script language=javascript>
<!--
function CheckForm()
{
if(document.form.Name.value=="")
{
alert("请您输入用户名!");
document.form.Name.focus();
return false;
}

if (document.form.email.value == "")
{
alert("请输入您的Email地址");
document.form.email.focus();
return false;
}

if (document.form.content.value==""){
alert ("请您正确填写你的信息!");
document.form.content.focus();
return false;
}

}
//-->
</script>
<f