请将 name="submit" 的type属性改为"button"即可,因为type="submit"的按钮是form的默认提交按钮,你就是不在它的onclick中写submit()函数,它也会将form提交的。
解决方案 »
- jQuery 插件问题为什么许多插件在都会用到 return this.each(function(){})
- extjs4 panel重新加载问题
- JQuery中多个hover事件怎么才能只处理一个,其他的忽略
- 关于URL转跳的问题
- onkeydown得到TEXT内当前输入
- 原本运行正常的JS加入正则表达式判断后无法工作~~~~
- 输入123,输出壹百贰拾叁,用js怎么办到?
- 在FireFox中如何调用Window Media Player控件中的play等方法和一些属性
- 求助一个辨别字符的FUNCTION,好不容易找到个函数,居然没用,在线等!
- 如何屏蔽掉F1键
- help
- 关闭一个窗口,有不弹出对话框的对象吗??
<script language=javascript>
<!--
function connect(){
if(indexform.UserID.value!="" && indexform.UserPW.value!=""){
indexform.submit();
}
else{
alert("请全部填写后再次提交。谢谢合作!");
return false
}
} //打开注册窗口function register() {
msg=window.open('register/Read.htm', '注册新用户', 'toolbar=no',
'location=no',
'directories=no',
'status=yes',
'menubar=yes',
'scrollbars=yes',
'resizable=no',
'copyhistory=yes',
'width=0','height=400'); //改变这些参数,决定弹出窗口的大小及是否有工具栏,滚动栏等。
}
//-->
</script> <html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><body bgcolor="#FFFFFF" text="#000000">
<form name="indexform" method="post" action="userlogin.jsp">
用户名:
<input type="text" name="UserID" size="16">
密码:
<input type="password" name="UserPW" size="12">
<input type="submit" name="submit" value="进入" onClick="return connect();">
<input type="button" value="注册" onClick="javascript:register();">
</form>
<p> </p></body>
</html>
中的检测放到<form name=frm onsubmit="connect();">
<script language=javascript>
<!--
function connect()
{
if(indexform.UserID.value!="" && indexform.UserPW.value!="")
{
return true;
}
else
{
alert("请全部填写后再次提交。谢谢合作!");
return false
}
} //打开注册窗口function register() {
msg=window.open('register/Read.htm', '注册新用户', 'toolbar=no',
'location=no',
'directories=no',
'status=yes',
'menubar=yes',
'scrollbars=yes',
'resizable=no',
'copyhistory=yes',
'width=0','height=400'); //改变这些参数,决定弹出窗口的大小及是否有工具栏,滚动栏等。
}
//-->
</script> <html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><body bgcolor="#FFFFFF" text="#000000">
<form name="indexform" method="post" action="userlogin.jsp">
用户名:
<input type="text" name="UserID" size="16">
密码:
<input type="password" name="UserPW" size="12">
<input type="submit" name="submit" value="进入" onClick="return connect();">
<input type="button" value="注册" onClick="javascript:register();">
</form>
<p> </p></body>
</html>
richardluopeng(罗罗)说的不对,要想在<form>里提交的话,也的给个返回值才行,所以应该是<form name=frm onsubmit="return connect();">
把它的type也改成button其它的什么都不用改了