当前位置:网站首页>Show or hide password plaintext + password box verification information
Show or hide password plaintext + password box verification information
2022-07-24 18:20:00 【lalaxuan】
️ Show or hide password plaintext Common functions and practices of unlocking the front-end password box 
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style> .box {
position: relative; width: 400px; border: 1px solid #ccc; margin: 100px auto; } .box input {
width: 370px; height: 30px; border: 0; outline: none; } .box .image {
position: absolute; right: 2px; top: 4px; border: 1px solid #ccc; background-color: #ccccccba; border-radius: 50%; /* Hide the four corners of the picture with more boxes */ overflow: hidden; } .box img {
/* Parent box is img open Remove the gap below */ vertical-align: bottom; width: 22px; } </style>
</head>
<body>
<div class="box">
<!-- picture -->
<div class="image">
<img src="img/close.png" alt="" id="img">
</div>
<!-- Password box -->
<input type="password" id="pwd">
</div>
<script> var img = document.getElementById('img'); var pwd = document.getElementById('pwd'); var flag = 0; img.onclick = function() {
if(flag == 0) {
pwd.type = 'text'; // this Point to the caller of the event function namely img this.src = 'img/eye.png'; flag = 1; }else {
pwd.type = 'password'; this.src = 'img/close.png'; flag = 0; } } </script>
</body>
</html>
Password box authentication information 
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style> .register {
width: 600px; margin: 100px auto; } .ipt {
width: 300px; border: 1px solid #999; outline: none; } .message {
display: inline-block; height: 20px; font-size: 12px; color: #999; /* After adding pictures Add left inner margin to the text Move the text to the right without blocking the picture */ background: url(img/maohao.png) no-repeat left center; padding-left: 30px; } .wrong {
color: red; background: url(img/error.png) no-repeat left center; } .right {
color: green; background: url(img/right.png) no-repeat left center; } </style>
</head>
<body>
<div class="register">
<input type="password" class="ipt">
<p class="message"> Please enter 6-16 Bit code </p>
</div>
<script> var ipt = document.querySelector('.ipt'); var msg = document.querySelector('.message'); // Use the above method Realization Press down enter Keys don't judge Use onchange Sure // // Forms When you get the focus Border discoloration // ipt.onfocus = function() {
// this.style.borderColor = 'skyblue'; // } // // Forms lose focus The border reverts to its original color And judge the number of bits and add the class name Change the text content // ipt.onblur = function() {
// this.style.borderColor = '#999'; // if(this.value.length < 6 || this.value.length > 16) {
// msg.className = 'message wrong'; // msg.innerHTML = ' The number of digits you entered does not meet the requirements 6-16 position '; // }else {
// msg.className = 'message right'; // msg.innerHTML = ' Input correct !'; // } // } ipt.onchange = function() {
if(this.value.length < 6 || this.value.length > 16) {
msg.className = 'message wrong'; msg.innerHTML = ' The number of digits you entered does not conform to the rule '; }else {
msg.className = 'message right'; msg.innerHTML = ' Input correct '; } } </script>
</body>
</html>
边栏推荐
- JumpServer的使用
- Example of single table query in ORM student management system
- Simple test JS code
- Icml2022 Best Paper Award: learning protein reverse folding from millions of predicted structures
- 剑指 Offer 21. 调整数组顺序使奇数位于偶数前面
- ORM student management system
- odoo中的bom理解
- Inherit, override, overload
- 【刷题记录】20. 有效的括号
- [OBS] dependency Library: x264 vs Build
猜你喜欢

下拉列表组件使用 iScroll.js 实现滚动效果遇到的坑

Laravel笔记-用户登录时密码进行RSA加密(提高系统安全性)

How to render millions of 2D objects smoothly with webgpu?

【刷题记录】20. 有效的括号

T245982 "kdoi-01" drunken flower Yin

6126. 设计食物评分系统

关于接口的写法 1链式判读 ?. 2方法执行 (finally)一定会执行

Section 7 Data Dictionary: hash followed by Daewoo redis ------- directory post

6126. Design food scoring system

Inherit, override, overload
随机推荐
sklearn 的模型保存与加载使用
Inherit, override, overload
Single cell code analysis - gynecological cancer single cell transcriptome and chromatin accessibility analysis 1
mysql 配置文件
如何向 google colab 快速上传文件
0627~ holiday knowledge summary
Variable and immutable data types
Has polardb for PostgreSQL entered the list of Xinchuang database?
Laravel notes - RSA encryption of user login password (improve system security)
Template inheritance and import
Common methods of array (2)
Bib | mol2context vec: context aware deep network model learning molecular representation for drug discovery
Get the original data API on 1688app
jmeter -- prometheus+grafana服务器性能可视化
Pycharm configuring opencv Library
How to render millions of 2D objects smoothly with webgpu?
undefined reference to H5PTopen
Introduction and use of Pinia
[record of question brushing] 20. Valid brackets
猜JWT关键字