asp的输入框判断语句怎么写啊
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "><html xmlns=" http://www.w3.org/1999/xhtml "><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>请输入</title></head><body><form name="form1" method="post" action="add_new.asp">帐号<input type="text" name="name"><br>密码<input type="text" name="content"><br><保护<input type="text" name="title" value=""><br><input type="submit" name="Submit" value="提交"><input type="reset" name="Submit2" value="重置"></form></body></html>比如就加一个,没输入帐号或密码的,就提示帐号密码不可以为空的代码,急啊,在这段代码上加就可以,谢谢,别乱弄一堆东西来
展开
展开全部
最好在客户端进行检查,在表单提交事件中执行检测
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 11 February 2007), see www.w3.org" />
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<script >
function checkform()
{
if (document.form1.name.value=="")
{
alert('请输入用户名');
return false;
}
else if (document.form1.content.value=="")
{
alert('请输入密码');
return false;
}
// If the script gets this far through all of your fields
// without problems, it's ok and you can submit the form
return true;
}
</script>
<title>请输入</title>
</head>
<body>
<form name="form1" method="post" action="add_new.asp" id="form1" onSubmit="return checkform()">
帐号<input type="text" name="name"><br />
密码<input type="text" name="content" /><br />
保护<input type="text" name="title" value= "" /><br />
<input type="submit" name="Submit" value="提交" /><input type=
"reset" name="Submit2" value="重置" />
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 11 February 2007), see www.w3.org" />
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<script >
function checkform()
{
if (document.form1.name.value=="")
{
alert('请输入用户名');
return false;
}
else if (document.form1.content.value=="")
{
alert('请输入密码');
return false;
}
// If the script gets this far through all of your fields
// without problems, it's ok and you can submit the form
return true;
}
</script>
<title>请输入</title>
</head>
<body>
<form name="form1" method="post" action="add_new.asp" id="form1" onSubmit="return checkform()">
帐号<input type="text" name="name"><br />
密码<input type="text" name="content" /><br />
保护<input type="text" name="title" value= "" /><br />
<input type="submit" name="Submit" value="提交" /><input type=
"reset" name="Submit2" value="重置" />
</form>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询