为啥在form里面按钮的js失效了

<form id="form" method="post">
用户名:<input id="username" name="username" type="text"/>
密码:<input id="password" name="password" type="password"/>
<input id="register" onclick="login()" type="submit" value="登陆"/>
<input id="reset" type="reset" value="重置"/>
</form>
第一个页面中有一个form,点击登陆按钮会给form添加一个action,跳转到页面2,然后页面2上还是同样的form,跳转到页面3,可是第一个跳转可以,到第二个页面点了按钮就没反应了,要把form去掉点了才有js的响应。
求高人指点
改成Button后还是一样,而且为啥把按钮移到form外面就有响应了?还有第一个表单就没问题。
这是页面2的form
<form id="form" method="post">
用户名:<input id="username" name="username" type="text"/><span>*6~20个字符</span><br>
密码:<input id="password" name="password" type="text"/><span>*8~20个字符</span><br>
确认密码:<input id="password2" name="password" type="text"/><span>*8~20个字符</span><br>
<button id="register" onclick="register()">注册</button>
<input id="reset" type="reset" value="重置"/>
</form>

onclick="login()" 和type="submit"两个冲突了,你不如将type改为button试试,另外你可以给form表单添加onsubmit方法,而不需要在下面用onclick方法
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-08-14
第2个页面是不是表单名称重复了呀