Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/441.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何";onclick=";location.href=''&引用;对于html按钮,对于用户登录,仅在验证凭据之后?_Javascript_Html - Fatal编程技术网

Javascript 如何";onclick=";location.href=''&引用;对于html按钮,对于用户登录,仅在验证凭据之后?

Javascript 如何";onclick=";location.href=''&引用;对于html按钮,对于用户登录,仅在验证凭据之后?,javascript,html,Javascript,Html,我正在尝试为web应用程序创建登录页。 如何在验证用户名和密码后仅允许按钮onclick=“” 以下是我所拥有的: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Customer Login</title> <meta http-e

我正在尝试为web应用程序创建登录页。 如何在验证用户名和密码后仅允许按钮onclick=“”

以下是我所拥有的:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Customer Login</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Language" content="ch-cn">
<script>

    function validate() {
        var uname = document.getElementById("uname");
        var upass = document.getElementById("upass");
        if(uname.value == ""){
            alert("username can't be null");
            return false;
        }

        else if(upass.value ==""){
            alert("password can't be null");
            return false;
        }
        else
            return true;
    }

</script>
</head>
<body>
    This is the Customer login page.
    <br>
    <form method="post" action="custlogin">
        user SSN:<input type="text" id="uname" name="userSSN"><br>
        <br> password:<input type="password" id="upass" name="pwd"><br>
        <br>
        <button type="submit" value="submit" onclick="return validate();">submit</button>
        <button type="reset" value="reset">reset</button>
    </form>
</body>
</html>

客户登录
函数验证(){
var uname=document.getElementById(“uname”);
var upass=document.getElementById(“upass”);
如果(uname.value==“”){
警报(“用户名不能为空”);
返回false;
}
else if(upass.value==“”){
警报(“密码不能为空”);
返回false;
}
其他的
返回true;
}
这是客户登录页面。

用户SSN:

密码:

提交 重置
您将哪些有效用户名和密码的信息存储在哪里? 数据库

我想帮忙,但我不是专家

据我所知,需要根据数据库中已保存内容的值测试输入值

差不多

具有ID为用户名、密码的表单字段

if {
userName == howeverYouReferenceAusernameindb
&& passWord == @tablename.columnName 
{
login code here
}
else { "please put valid creds"
}
}