JavaScript提交表单问题
functiontijiao(){if(document.login.username.value==""){alert("请输入管理员帐号");document.log...
function tijiao(){
if(document.login.username.value=="")
{
alert("请输入管理员帐号");
document.login.username.focus();
return false;
}
if(document.login.userpass.value=="")
{
alert("请输入管理员密码");
document.login.userpass.focus();
return false;
}
document.login.submit();
}
我这个不对吗?为什么表单提交不了啊 展开
if(document.login.username.value=="")
{
alert("请输入管理员帐号");
document.login.username.focus();
return false;
}
if(document.login.userpass.value=="")
{
alert("请输入管理员密码");
document.login.userpass.focus();
return false;
}
document.login.submit();
}
我这个不对吗?为什么表单提交不了啊 展开
2个回答
展开全部
<!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>
<script language="JavaScript">
<!--
function exam()
{
var t1=document.form1.textfield.value;
if(!t1){
alert("请输入用户名");
document.form1.textfield.focus();
return false;
}
var t2=document.form1.textfield2.value;
if(!t2){
alert("请输入密码");
document.form1.textfield2.focus();
return false;
}
return true;
}
//-->
</script>
</head>
<body>
<form id="form1" name="form1" method="post" onsubmit="return exam();" action="">
<table width="293" border="1">
<tr>
<td width="95" height="35">登陆用户名</td>
<td width="182"><label>
<input type="text" name="textfield" />
</label></td>
</tr>
<tr>
<td>密码</td>
<td width="182"><input type="password" name="textfield2" /></td>
</tr>
<td colspan="2" align="center"><input type="submit" name="Submit" value="提交" />
<input type="reset" name="Submit2" value="重置" /></td>
</tr>
</table>
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="JavaScript">
<!--
function exam()
{
var t1=document.form1.textfield.value;
if(!t1){
alert("请输入用户名");
document.form1.textfield.focus();
return false;
}
var t2=document.form1.textfield2.value;
if(!t2){
alert("请输入密码");
document.form1.textfield2.focus();
return false;
}
return true;
}
//-->
</script>
</head>
<body>
<form id="form1" name="form1" method="post" onsubmit="return exam();" action="">
<table width="293" border="1">
<tr>
<td width="95" height="35">登陆用户名</td>
<td width="182"><label>
<input type="text" name="textfield" />
</label></td>
</tr>
<tr>
<td>密码</td>
<td width="182"><input type="password" name="textfield2" /></td>
</tr>
<td colspan="2" align="center"><input type="submit" name="Submit" value="提交" />
<input type="reset" name="Submit2" value="重置" /></td>
</tr>
</table>
</form>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询