Sometimes it is necessary to perform simple verification on the front-end page when the user inputs to reduce the pressure on the server For example, to limit the input length of a field: There is an input range prompt message after the input box. If you enter the wrong length, it will become an error prompt message. If you enter the correct length, the correct prompt message will be displayed. Implementation ideas 1. Write the input prompt information first. Sample Code<!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>Password box input prompt</title> <style> div { width: 600px; margin: 100px auto; } input { outline: none; } .message { display: inline-block; font-size: 12px; color: #999; background: url(images/提示.png) no-repeat left center/16px 16px; padding-left: 20px; } .wrong { background-image: url(images/error.png); color: red; } .right { background-image: url(images/correct.png); color: green; } </style> </head> <body> <div class="register"> <input type="password" class="inp"> <p class="message">Please enter a 8-18 digit password</p> </div> <script> var password = document.querySelector('.inp'); var message = document.querySelector('.message'); password.onblur = function() { if (this.value.length < 8 || this.value.length > 18) { message.innerHTML = 'The password length is incorrect, it should be 8 to 18 characters'; message.className = 'message wrong'; } else { message.innerHTML = 'The password length is correct'; message.className = 'message right'; } } </script> </body> </html> Page effect: 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 where the images pulled by docker are stored
>>: What does the n after int(n) in MySQL mean?
Docker provides multiple networks such as bridge,...
need: According to business requirements, it is n...
Table of contents Introduction question Design 1:...
It was found in the test that when the page defini...
<br />For an article on a content page, if t...
Grid layout Attributes added to the parent elemen...
Table of contents The basic principle of MySQL ma...
This article mainly introduces the example analys...
Precautions 1) Add interpreter at the beginning: ...
1. Create a new configuration file docker_nginx.c...
0 Differences between icons and images Icons are ...
The layout of text has some formatting requiremen...
Open DREAMWEAVER and create a new HTML. . Propert...
Docker is a management tool that uses processes a...
Table of contents 1. props/$emit Introduction Cod...