This article example shares the specific code of JavaScript to implement password box verification information for your reference. The specific content is as follows <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> div { width: 600px; margin: 100px auto; } .message { display: inline-block; font-size: 12px; color: #999; background: url(./img/1.png) no-repeat left center; padding-left: 10px; } .wrong { color: red; background-image: url(img/2.png); } .right { color: green; background-image: url(img/3.png); } </style> </head> <body> <div class="register"> <input type="password" class="ipt"> <p class="message">Please enter a 6-16 digit password</p> </div> <script> //Get the element var ipt = document.querySelector('.ipt'); var message = document.querySelector('.message'); //Register event ipt.onblur = function() { //According to the length of the form valueif (this.value.length < 6 || this.value.length > 16) { message.className = 'message wrong'; message.innerHTML = 'The number of digits you entered is incorrect'; } else { message.className = 'message right'; message.innerHTML = 'Enter correctly'; } } </script> </body> </html> Operation Results The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Detailed explanation of the deployment process of Docker Alibaba Cloud RocketMQ 4.5.1
>>: Example sharing of anchor tag usage in HTML
Suddenly, I needed to build a private service for...
This article uses examples to illustrate the func...
Table of contents 1. Introduction 2. Implementati...
Table of contents Preface 1. Technical Principle ...
Table of contents What is a headless browser? Why...
question In LINUX, periodic tasks are usually han...
As usual, let’s first post the picture effect: Th...
<br />We usually declare DOCTYPE in HTML in ...
This article introduces the sample code of CSS to...
The installation of MySQL 8.0.12 took two days an...
Preface As a heavy user of front-end frameworks, ...
Preface I recently sorted out my previous notes o...
Table of contents Introduction and Demo API: Cont...
There are many servers that can host static websi...
Introduction react-i18next is a powerful internat...