Home > Backend Development > PHP Tutorial > 新手求问,关于js登录验证有关问题

新手求问,关于js登录验证有关问题

WBOY
Release: 2016-06-13 10:15:12
Original
1041 people have browsed it

新手求问,关于js登录验证问题

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><script type="text/javascript">    function logincheck(){        if (loginform.user.value=""){            alert ("请输入用户名");            loginform.user.focus();            return false;            }        if (loginform.pw.value=""){            alert ("请输入用户名");            loginform.pw.focus();            return false;            }    }</script>    <div id="login">             <div id="top">           <div id="top_left"><img  src="images/login_03.gif" alt="新手求问,关于js登录验证有关问题" ></div>              <div id="top_center"></div>         </div>         <form action="login.php" method="post" name="loginform" onsubmit="return logincheck(this);">             <div id="center">                  <div id="center_left"></div>                  <div id="center_middle">                       <div id="user">用 户                         <input type="text" name="user">                       </div>                       <div id="password">密   码                         <input type="password" name="pw">                       </div>                       <div id="btn">                        <input type="submit" value="登录" name="submit">                        <input type="reset" value="取消" name="reset">                       </div>                                    </div>                  <div id="center_right"></div>                      </div>         </form>         <div id="down">              <div id="down_left">                  <div id="inf">                       <span class="inf_text">版本信息</span>                       <span class="copyright">留言管理系统 2012 v1.0</span>                  </div>              </div>              <div id="down_center"></div>                  </div>    </div>
Copy after login

以上是部分代码,网上找了很多帖子,但是依然没有效果,不明白为什么不执行,求教

------解决方案--------------------
function logincheck(){
if (loginform.user.value==""){
alert ("请输入用户名");
loginform.user.focus();
return false;
}
if (loginform.pw.value==""){
alert ("请输入用户名");
loginform.pw.focus();
return false;
}
}

------解决方案--------------------
if (loginform.user.value=""){

判断 == ?
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template