You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

HTML网页密码隐藏方法求助:输入框如何显示为圆点或星号

解决密码输入框显示圆点/星号的问题

嘿,作为HTML新手碰到这个问题太正常啦!其实你只需要给密码输入框加个简单的属性就能搞定——把输入框的type设为password就行,浏览器会自动把输入内容转换成圆点或者星号显示~

关键修改点

原来你可能用的是普通文本输入框(type="text"),现在把它改成:

<input type="password" placeholder="请输入密码">

整合到你的代码里的完整示例

我把你的代码补全并修改了关键部分,你可以直接用:

<html>
<body>
    <img src="logo page.jpg" alt="TCIL" width="1590" height="470">
    <p>
        <font color="blue" size="5">
            <center>Corporate Social Responsibility</center>
        </font>
    </p>
    <!-- 这里是修改后的密码输入区域 -->
    <div style="text-align:center;">
        <label for="pwd">请输入密码:</label>
        <input type="password" id="pwd" name="password">
        <button onclick="checkPassword()">提交</button>
    </div>

    <SCRIPT>
        // 这是一个基础的密码校验示例,你可以根据需求修改
        function checkPassword() {
            const inputPwd = document.getElementById('pwd').value;
            // 替换成你实际的正确密码和跳转页面
            if (inputPwd === 'yourValidPassword') {
                window.location.href = 'target-page.html';
            } else {
                alert('密码错误,请重试!');
            }
        }
    </SCRIPT>
</body>
</html>

小提示

  • placeholder是输入框的提示文字,可选,你可以根据需要调整或删除
  • 脚本里的校验逻辑只是参考,记得把示例里的密码和跳转路径换成你实际要用的内容

内容的提问来源于stack exchange,提问作者Ashish Prasad

火山引擎 最新活动