HTML的密码校对,之前还可以提示密码是否一样,现在提示不了


<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>欢迎加入</title>
<link type="text/css" rel="stylesheet"    href="注册样式.css">
<link type="text/css" rel="stylesheet"    href="轮播图片.css">    
</head>

<body>
<script type="text/javascript" src="js/jquery-3.5.1/jquery-3.5.1.min.js"></script>    

<div id="container"    >    
<!--图片播放-->
<div id="div0">
    
    <div class="picture">
    
    <div class="picture-1"><img src="轮播图/1.jpg" alt="图片丢失" height="936" width="1518"> </div>
    <div class="picture-1"><img src="轮播图/2.jpg" alt="图片丢失" height="936" width="1518"> </div>
    <div class="picture-1"><img src="轮播图/3.jpg" alt="图片丢失" height="936" width="1518"> </div>
    

</div>    

<script type="text/ecmascript">
    $(function(){
        var index=0;
        setInterval(function(){
            if(index==$(".picture-1").length-1){
             index=0;
            $(".picture-1").css("opacity","0");
            $(".picture-1").eq(index).css("opacity","1");
            }
            
            else{
            index++;
            $(".picture-1").css("opacity","0");
            $(".picture-1").eq(index).css("opacity","1");
            }
        },2000)
    })    
</script>    
</div>    
<!--用户名密码检查-->
<script type="text/javascript">
var temp;
var tempp;
var temppp;
function checkpassword()
{
var pw1=document.getElementById("pwd1").value;
temp=pw1;
var pw2=document.getElementById("pwd2").value;
tempp=pw2;
var user=document.getElementById("user").value;
temppp=user;
}

function ps()
{
var pw1=temp;
var pw2=tempp;
var user=temppp;
    
if(!user)    
{
    alert("用户名不能为空");
}    
else{
if(!pw1)
  {    
    alert("请输入密码");
}
    else{
if(!pw2){
        alert("请确认密码");        
}
    else{
    if(pw1!=pw2){
        alert("密码不一致");
    }
        else{    
        alert("注册成功");
        }
}    
    }
}    
}
    
</script>

    

    
<div id="div1">        

<form action="http://192.168.1.17/" method="post">     
<div id="div2">
        <font size="5" ><a href="登录.html">登录</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="注册.html">注册</a></font>
</div>    
<div id="div22"></div>    
    
<div id="div21" >
        用户类别:<input type="radio" name="t"    value="0"    checked="checked">学生
                <input type="radio" name="t" value="1">老师
                <input type="radio" name="t" value="2">管理员
</div>
<div id="div3" >        
    <input style="width: 250px;height: 40px;border-radius: 10px;"  type="text" placeholder="用户名" id="user"  name="userr"  >
</div>        
<div id="div4">
    <input  style="width: 250px;height: 40px;border-radius: 10px;"  type="password" placeholder="密码" id="pwd1"  name="pwd11" >    
</div>
<div id="div5">
    <input  style="width: 250px;height: 40px;border-radius: 10px;"  type="password" placeholder="请确认密码"   id="pwd2"  name="pwd21" onkeyup="checkpassword()" >    
    
</div>
    <div id="div6">
    <input type="submit" value="注册" style="width:250px;height:50px" class="yanse"  onclick="ps()">
</div>
</form>
<!--对错小图标
<div id="div7"></div>
<div id="div8"></div>
-->
</div>
</div>    
    
</body>
</html>

    alert("注册成功")之后的分号写成了中文全角的,要改成英文半角的。

你题目的解答代码如下:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>欢迎加入</title>
<link type="text/css" rel="stylesheet"    href="注册样式.css">
<link type="text/css" rel="stylesheet"    href="轮播图片.css">    
</head>
 
<body>
<script type="text/javascript" src="js/jquery-3.5.1/jquery-3.5.1.min.js"></script>    
 
<div id="container"    >    
<!--图片播放-->
<div id="div0">
    
    <div class="picture">
    
    <div class="picture-1"><img src="轮播图/1.jpg" alt="图片丢失" height="936" width="1518"> </div>
    <div class="picture-1"><img src="轮播图/2.jpg" alt="图片丢失" height="936" width="1518"> </div>
    <div class="picture-1"><img src="轮播图/3.jpg" alt="图片丢失" height="936" width="1518"> </div>
    
 
</div>    
 
<script type="text/ecmascript">
    $(function(){
        var index=0;
        setInterval(function(){
            if(index==$(".picture-1").length-1){
             index=0;
            $(".picture-1").css("opacity","0");
            $(".picture-1").eq(index).css("opacity","1");
            }
            
            else{
            index++;
            $(".picture-1").css("opacity","0");
            $(".picture-1").eq(index).css("opacity","1");
            }
        },2000)
    })    
</script>    
</div>    
<!--用户名密码检查-->
<script type="text/javascript">
 
function ps() {
    var pw1 = document.getElementById("pwd1").value;
    var pw2 = document.getElementById("pwd2").value;
    var user = document.getElementById("user").value;

    if (user == "") {
        alert("用户名不能为空");
    } else {
        if (pw1 == "") {
            alert("请输入密码");
        } else {
            if (pw2 == "") {
                alert("请确认密码");
            } else {
                if (pw1 != pw2) {
                    alert("密码不一致");
                } else {
                    alert("注册成功");
                }
            }
        }
    }
}    
</script>
 
    
 
    
<div id="div1">        
 
<form action="http://192.168.1.17/" method="post">     
<div id="div2">
        <font size="5" ><a href="登录.html">登录</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="注册.html">注册</a></font>
</div>    
<div id="div22"></div>    
    
<div id="div21" >
        用户类别:<input type="radio" name="t"    value="0"    checked="checked">学生
                <input type="radio" name="t" value="1">老师
                <input type="radio" name="t" value="2">管理员
</div>
<div id="div3" >        
    <input style="width: 250px;height: 40px;border-radius: 10px;"  type="text" placeholder="用户名" id="user"  name="userr"  >
</div>        
<div id="div4">
    <input  style="width: 250px;height: 40px;border-radius: 10px;"  type="password" placeholder="密码" id="pwd1"  name="pwd11" >    
</div>
<div id="div5">
    <input  style="width: 250px;height: 40px;border-radius: 10px;"  type="password" placeholder="请确认密码"   id="pwd2"  name="pwd21" >    
    
</div>
    <div id="div6">
    <input type="submit" value="注册" style="width:250px;height:50px" class="yanse"  onclick="ps()">
</div>
</form>
<!--对错小图标
<div id="div7"></div>
<div id="div8"></div>
-->
</div>
</div>    
    
</body>
</html>
 

如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!

img

远程看看吧

远程看看吧

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632