glimmert 2015-12-28 15:04 采纳率: 100%
浏览 1483
已采纳

这个验证跳转总是失败,实在不知道错在哪,可以帮我看看吗?

图片说明



主页登陆
<br> function check() {<br> if (document.forms(0).name.value == &quot;123&quot; &amp;&amp; document.forms(0).pw.value == &quot;123456&quot;) {<br> window.location = &quot;body.html&quot;;<br> }<br> else {<br> alert(&quot;用户名不正确或则密码不正确&quot;); return false;<br> }<br> }<br>

    <form name="myform" action="###" method="post" onsubmit="check()">
        <label for="name"> 账号:</label><input type="text" size="20" value="" placeholder="请输入账号" name="name" id="name" /><br />
      <label for="pw" >  密码:</label><input type="password" id="pw" name="pw" placeholder="请输入密码" value="" /><br />
        <input type="submit" value="登录" /><input type="reset" value="重置" />
    </form>


  • 写回答

4条回答 默认 最新

  • 普通网友 2015-12-28 16:41
    关注

    From 的onsubmit应该是 onsubmit="return check()"

    事件里面要返回一个布尔值

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?