JS, CSS and HTML to implement the registration page

JS, CSS and HTML to implement the registration page

A registration page template implemented with HTML and CSS. Without further ado, here’s the code!

Update: Use JavaScript to implement username and password form validation.

The code is as follows:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Registration Page</title>
    <style>
        *{
            margin: 0px;
            padding: 0px;
            box-sizing: border-box;
        }
        body{
            background: url("img/register_bg.png") no-repeat center;
            padding-top: 25px;
        }

        .rg_layout{
            width: 900px;
            height: 500px;
            border: 8px solid #EEEEEE;
            background-color: white;
            /* Center the div horizontally */
            margin: auto;
        }

        .rg_left{
            /*border: 1px solid red;*/
            float: left;
            margin: 15px;
        }
        .rg_left > p:first-child{
            color:#FFD026;
            font-size: 20px;
        }

        .rg_left > p:last-child{
            color:#A6A6A6;
            font-size: 20px;

        }
        .rg_center{
            float: left;
            /* border: 1px solid red;*/

        }

        .rg_right{
            /*border: 1px solid red;*/
            float: right;
            margin: 15px;
        }

        .rg_right > p:first-child{
            font-size: 15px;

        }
        .rg_right pa {
            color:pink;
        }

        .td_left{
            width: 100px;
            text-align: right;
            height: 45px;
        }
        .td_right{
            padding-left: 50px ;
        }

        #username,#password,#email,#name,#tel,#birthday,#checkcode{
            width: 251px;
            height: 32px;
            border: 1px solid #A6A6A6 ;
            /*Set border radius*/
            border-radius: 5px;
            padding-left: 10px;
        }
        #checkcode{
            width: 110px;
        }

        #img_check{
            height: 32px;
            vertical-align: middle;
        }

        #btn_sub{
            width: 150px;
            height: 40px;
            background-color: #FFD026;
            border: 1px solid #FFD026 ;
        }
        .error {
            color: red;
        }
        #td_sub {
            padding-left: 150px;
        }

    </style>

    <script>
        //Implement account password form verification window.onload = function () {
            //Bind the onsubmit event to the form //That is, clicking the register button will verify whether the username and password are correct document.getElementById("form").onsubmit = function () {
                //Call the user verification method checkUsername();
                //Call the password verification method checkPassword();
                return checkUsername() && checkPassword();
            }

            //Bind the defocus event to the username and password respectively //When the focus is off, it will check whether the username and password are correct //Note that there are no brackets in the method here document.getElementById("username").onblur = checkUsername;
            document.getElementById("password").onblur = checkPassword;
        }

        //Check username function checkUsername() {
            //1. Get the value of the username var username = document.getElementById("username").value;
            //2. Define regular expression var reg_username = /^\w{6,12}$/;
            //3. Determine whether the value conforms to the regular rule var flag = reg_username.test(username);
            //4. Prompt information var s_username = document.getElementById("s_username");

            if (flag) {
                //Prompt green check mark s_username.innerHTML = "<img width='35' height='25' src='img/gou.png' />";
            } else {
                //Prompt that the red username is incorrect s_username.innerHTML = "The username format is incorrect";
            }
            return flag;
        }

        //Check password function checkPassword() {
            //1. Get the value of the username var password = document.getElementById("password").value;
            //2. Define regular expression var reg_password = /^\w{6,12}$/;
            //3. Determine whether the value conforms to the regular rule var flag = reg_password.test(password);
            //4. Prompt information var s_password = document.getElementById("s_password");

            if (flag) {
                //Prompt green check mark s_password.innerHTML = "<img width='35' height='25' src='img/gou.png' />";
            } else {
                //Prompt that the red username is incorrect s_password.innerHTML = "The password format is incorrect";
            }
            return flag;
        }


    </script>
</head>
<body>

<div class="rg_layout">
    <div class="rg_left">
        <p>New User Registration</p>
        <p>USER REGISTER</p>

    </div>

    <div class="rg_center">
        <div class="rg_form">
            <!--Define the form-->
            <form action="#" id="form" method="get">
                <table>
                    <tr>
                        <td class="td_left"><label for="username">Username</label></td>
                        <td class="td_right">
                            <input type="text" name="username" id="username" placeholder="Please enter your username">
                            <span id="s_username" class="error"></span>
                        </td>
                    </tr>

                    <tr>
                        <td class="td_left"><label for="password">Password</label></td>
                        <td class="td_right">
                            <input type="password" name="password" id="password" placeholder="Please enter your password">
                            <span id="s_password" class="error"></span>
                        </td>
                    </tr>

                    <tr>
                        <td class="td_left"><label for="email">Email</label></td>
                        <td class="td_right"><input type="email" name="email" id="email" placeholder="Please enter your email address"></td>
                    </tr>

                    <tr>
                        <td class="td_left"><label for="name">Name</label></td>
                        <td class="td_right"><input type="text" name="name" id="name" placeholder="Please enter your name"></td>
                    </tr>

                    <tr>
                        <td class="td_left"><label for="tel">Mobile number</label></td>
                        <td class="td_right"><input type="text" name="tel" id="tel" placeholder="Please enter your phone number"></td>
                    </tr>

                    <tr>
                        <td class="td_left"><label>Gender</label></td>
                        <td class="td_right">
                            <input type="radio" name="gender" value="male"> Male<input type="radio" name="gender" value="female"> Female</td>
                    </tr>

                    <tr>
                        <td class="td_left"><label for="birthday">Date of Birth</label></td>
                        <td class="td_right"><input type="date" name="birthday" id="birthday" placeholder="Please enter your date of birth"></td>
                    </tr>

                    <tr>
                        <td class="td_left"><label for="checkcode" >Verification code</label></td>
                        <td class="td_right"><input type="text" name="checkcode" id="checkcode" placeholder="Please enter the verification code">
                            <img id="img_check" src="img/verify_code.jpg">
                        </td>
                    </tr>

                    <tr>
                        <td colspan="2" id="td_sub"><input type="submit" id="btn_sub" value="Register"></td>
                    </tr>
                </table>

            </form>

        </div>

    </div>

    <div class="rg_right">
        <p>Already have an account?<a href="#" >Log in now</a></p>
    </div>

</div>
</body>
</html>

Operation 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:
  • HTML plus CSS style to achieve JS food project homepage sample code
  • HTML+CSS+JavaScript to make a girlfriend version of scratch card (you will learn it once you see it)
  • Detailed explanation of the use of HTML canvas and page storage technology in JavaScript
  • SpringMVC @RequestBody Date type Json conversion method
  • C# sends a POST request with JSON Body through HttpWebRequest
  • Solve the problem of @RequestBody receiving json object and reporting error 415
  • Let's talk about the relationship between @RequestBody and Json
  • Modify the style of HTML body in JS

<<:  Detailed tutorial on installing centos8 on VMware

>>:  Tutorial on how to install htop on CentOS 8

Recommend

How to set a fixed IP address in CentOS7 virtual machine

Since my development environment is to install Ce...

HTML basics HTML structure

What is an HTML file? HTML stands for Hyper Text M...

How to expand Linux swap memory

Swap memory mainly means that when the physical m...

Tomcat Server Getting Started Super Detailed Tutorial

Table of contents 1. Some concepts of Tomcat –1, ...

About nginx to implement jira reverse proxy

Summary: Configure nginx reverse proxy jira and i...

How to install mongodb 4.2 using yum on centos8

1. Make a repo file Refer to the official install...

Prevent HTML and JSP pages from being cached and re-fetched from the web server

After the user logs out, if the back button on the...

Introduction to Apache deployment of https in cryptography

Table of contents Purpose Experimental environmen...

Analysis of the Linux input subsystem framework principle

Input subsystem framework The linux input subsyst...

WeChat applet realizes the effect of shaking the sieve

This article shares the specific code of the WeCh...

In-depth analysis of MySQL indexes

Preface We know that index selection is the work ...

In-depth explanation of hidden fields, a new feature of MySQL 8.0

Preface MySQL version 8.0.23 adds a new feature: ...

Solve the problem that ifconfig and addr cannot see the IP address in Linux

1. Install the Linux system on the virtual machin...