Hello everyone, in this post, we will learn how to create a simple template signup form using HTML CSS, and JavaScript. We know that in the last post we discussed how to create a Signup form HTML code | Login form HTML template. But today in this post you will learn how to create a signup form using HTML CSS and JavaScript with the required fields.
Signup form in HTML, CSS and JavaScript
As you can see in the image we have created a signup form for our website. We use the signup form on our website. If we don’t have an account on the website or application. The signup form collects the basic information from the user and then creates an account for the user.
Signup form content
This sign-up form has a solid background color and it is created with the help of CSS properties. Then we have a heading at the top of the signup page and it is named “sign up”. It is created using the HTML tag H1. Below this, we have created the fields of the sign-up form and these fields are used for collecting the information from the user.
You might like it:
In these fields, we are collecting first name, last name, email, password, and confirm password from the user. These fields are created with the help of an input tag in HTML. As you can see in the fields that we have a red star appeared in these fields and these fields are required fields. Without inserting data into these fields you cannot click on the sign-up button.
Below this field, we have a checkbox and it is known as “I agree with terms and conditions”. The checkbox is already checked and you can uncheck it but then you are unable to create your account on the website.
Then we created a button of sign up and it is designed with the help of CSS properties. If you have already an account on the website then you have to click on the sign-in button. And then you have no need to fill sign up form. If you want to check the terms and privacy policy of the website then you can click it below link.
So, if you want to know how to create this type of sign-up form using HTML, CSS and JavaScript then follow the below steps. After following these steps you will be able to create a signup form using HTML CSS and JavaScript.
How to create a signup form?
For creating the signup form we will follow four steps. By following these steps you will be able to create this type of sign-up form.
Download a code editor
It is the first step of creating a signup form and you have to download a code editor. Code editor provides the developer with an environment to write the code. It saves time developer and helps the developer to write the code without Syntax errors. You can use any code editor to write the code CSS and JavaScript but vs code is recommended.
Source code of HTML
After downloading the code editor first of all you have to create a file with the name of the form. Html. Now the code of HTML is given below and you have to copy this code and paste it into your created HTML file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
<!Doctype html> <html> <head> <meta charset="utf-8"> <title>Login and Signup form - FantacyDesigns </title> <link rel="stylesheet" href="style.css"> <link rel="JavaSctipt" href="script.js"> <link href="https://fonts.googleapis.com/css2?family=Jost:wght@500&display=swap" rel="stylesheet"> </head> <body> <main class="sign-up"> <div class="sign-up__content"> <header class="sign-up__header"> <h1 class="sign-up__title"> Sign up </h1> <p class="sign-up__descr"> Welcome, Please sign up your account. </p> </header> <form class="sign-up__form form"> <div class="form__row form__row--two"> <div class="input form__inline-input"> <div class="input__container"> <input class="input__field" id="first-name" placeholder="First Name" required="" type="text" /><label class="input__label" for="first-name">First Name</label> </div> </div> <div class="input form__inline-input"> <div class="input__container"> <input class="input__field" id="last-name" placeholder="Last Name" required="" type="text" /><label class="input__label" for="last-name">Last Name</label> </div> </div> </div> <div class="form__row"> <div class="input"> <div class="input__container"> <input class="input__field" id="username" placeholder="Username" type="text" /><label class="input__label" for="username">User Name</label> </div> </div> </div> <div class="form__row"> <div class="input"> <div class="input__container"> <input class="input__field" id="email" placeholder="Email" required="" type="text" /><label class="input__label" for="email">Email</label> </div> </div> </div> <div class="form__row"> <div class="input"> <div class="input__container"> <input class="input__field" id="password" placeholder="Password" required="" type="password" /><label class="input__label" for="password">Password</label> </div> </div> </div> <div class="form__row"> <div class="input"> <div class="input__container"> <input class="input__field" id="confirm-password" placeholder="Confirm password" required="" type="password" /><label class="input__label" for="confirm-password">Confirm password</label> </div> </div> </div> <div class="form__row"> <div class="input-checkbox"> <div class="input-checkbox__container"> <input checked="" class="input-checkbox__field" id="agree" required="" tabindex="0" type="checkbox" /><span class="input-checkbox__square"></span><label class="input-checkbox__label" for="agree">I agree with terms and conditions</label> </div> </div> </div> <div class="form__row"> <div class="component component--primary form__button"> <button class="btn btn--regular" disabled="" id="sign-up-button" tabindex="0">Sign up</button> </div> </div> <div class="form__row sign-up__sign"> Already have an account? <a class="link" href="#">Sign in.</a> </div> <div class="form__row sign-up__terms"> <a class="link" href="#">Term of use. Privacy policy</a> </div> </form> </div> </div> </main> </body> </html> |
.
Source code of CSS
CSS is known as a markup language and we use this language for designing our landing pages and making them responsive across all devices. All the design in web pages is designed with the help of CSS properties. Now create a file for CSS in your code editor and then paste this code into your code editor.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
*, *::before, *::after { box-sizing: border-box; } body { font-family: "Source Sans Pro", sans-serif; font-size: 16px; line-height: 1.43; background-image: linear-gradient(to right top, #918fc1, #7d7bae, #69679b, #565488, #434176); } h1 { font-size: 2.5em; font-weight: bold; } input, button { appearance: none; outline: none; } input::-webkit-input-placeholder { color: transparent; user-select: none; } input::-moz-placeholder { color: transparent; user-select: none; } input:-moz-placeholder { color: transparent; user-select: none; } input:-ms-input-placeholder { color: transparent; user-select: none; } input:-webkit-autofill { -webkit-box-shadow: 0 0 0 100px #fff inset; -webkit-text-fill-color: inherit; } .input { flex: 1; width: 100%; transition: width 0.18s ease; } .input__container { display: flex; flex-direction: column; position: relative; height: 40px; width: 100%; } .input__container.error { height: auto; } .input__container.error pre { padding: 8px 8px 0; } .input__label { position: absolute; padding: 0 8px; top: 0; color: #3d3c48; cursor: text; font-size: 16px; transition-property: top, font-size; transition-timing-function: linear; transition-duration: 0.18s; } .input__field { background: transparent; border: 0px solid #e5e5e6; border-bottom-width: 2px; padding: 6px 8px; font-size: 16px; transition: border 0.28s ease-out; } .input__field:required + .input__label:after { content: "*"; color: red; } .input__field:focus, .input__field:not(:placeholder-shown) { border-color: #434176; } .input__field:focus + .input__label, .input__field:not(:placeholder-shown) + .input__label { font-size: 14px; top: -16px; } .input:hover .input__field:placeholder-shown:not(:focus) { border-color: #918fc1; } .input-checkbox__field { position: absolute; height: 18px; width: 18px; margin: 0; cursor: pointer; opacity: 0; z-index: 1; } .input-checkbox__container { display: flex; flex-direction: row; align-items: center; } .input-checkbox__label { padding: 0 16px; color: #3d3c48; cursor: pointer; font-size: 16px; line-height: 1.25; } .input-checkbox__square { display: flex; align-items: center; justify-content: center; position: relative; height: 18px; width: 18px; border: 1px solid #c5c5c9; border-radius: 4px; will-change: border, box-shadow; transition: border 0.28s ease-out, box-shadow 0.28s ease-out; z-index: 0; } .input-checkbox__square::before, .input-checkbox__square::after { content: ""; display: inline-block; width: 2px; background: #e5e5e6; border-radius: 2px; transition: background 0.28s ease-out; } .input-checkbox__square::before { height: 4px; transform: rotate(-40deg) translate3d(-1.5px, 0px, 0); } .input-checkbox__square::after { height: 8px; transform: rotate(40deg); } .input-checkbox:hover .input-checkbox__square::before, .input-checkbox:hover .input-checkbox__square::after { background: #434176; } .input-checkbox__field:focus + .input-checkbox__square::before, .input-checkbox__field:focus + .input-checkbox__square::after, .input-checkbox__field:checked + .input-checkbox__square::before, .input-checkbox__field:checked + .input-checkbox__square::after { background: #434176; } .input-checkbox__field:hover + .input-checkbox__square { box-shadow: 0 1px 6px rgba(0, 0, 0, 0.32); } .input-checkbox__field:focus + .input-checkbox__square { box-shadow: 0 2px 12px rgba(0, 0, 0, 0.32); } .input-checkbox__field:checked + .input-checkbox__square { border-color: #434176; } .btn { border: none; border-radius: 4px; font-size: 18px; cursor: pointer; will-change: background, box-shadow; transition: background 0.28s ease-out, box-shadow 0.28s ease-out; } .btn--regular, .btn--line { padding: 16px 56px; } .btn--disabled { opacity: 0.4; pointer-events: none; } .component--primary .btn:disabled { opacity: 0.7; pointer-events: none; } .component--primary .btn--regular { background-color: #434176; color: #FFF; } .component--primary .btn--regular:hover { background-color: #6361a8; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); } .component--primary .btn--regular:focus, .component--primary .btn--regular:active { background-color: #34335c; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3); } .component--primary .btn--regular:disabled { background-color: #5c5c5c; } .link { text-decoration: none; color: #434176; display: inline-block; text-decoration: underline; transition: color 0.28s ease-out; } .link:hover { color: #161627; } .form { max-width: 400px; width: 100%; margin: 0 auto; } .form__row { margin-bottom: 40px; } .form__row--two { margin: 0 -16px 0px; } @media screen and (min-width: 500px) { .form__row--two { display: flex; } } .form__inline-input { padding: 0 16px; margin-bottom: 40px; } @media screen and (min-width: 500px) { .form__inline-input { width: 50%; flex: 1 0 auto; } } .form__button { text-align: center; cursor: pointer; } #sign-up-button{ background: #434176; } #sign-up-button:hover{ color: #434176; transition: .5s; background: #fff; border: 1px solid #434176; } .sign-up { min-height: 1000px; width: 600px; margin-left: auto; margin-right: auto; margin-left: 400px; } } .sign-up__image, .sign-up__content { flex: 1; } .sign-up__image { display: none; background-image: linear-gradient(210deg, #242348, #5A55AA); position: relative; overflow: hidden; } .sign-up__image svg { width: 100%; height: 100%; bottom: 0; top: 0; position: absolute; } @media screen and (min-width: 1000px) { .sign-up__image { display: block; } } .sign-up__content { margin-top: 100px; margin-bottom: 100px; display: flex; flex-flow: column nowrap; align-items: center; padding: 4vh 24px 10vh; background-color: #fff; width: 600px; box-shadow: rgba(0, 0, 0, 0.25) 0px 14px 28px; } .sign-up__header { margin-bottom: 48px; text-align: center; } .sign-up__title { margin-bottom: 16px; color: #434176; } .sign-up__descr { font-size: 1.25rem; color: rgba(67, 65, 118, 0.4); } .sign-up__form { width: 100%; } .sign-up__sign, .sign-up__terms { text-align: center; margin-bottom: 20px; } .sign-up__sign { margin-top: -8px; } .sign-up__terms { margin-top: 80px; } .chart .a { fill: url(#a); } .chart .b { clip-path: url(#b); } .chart .c { opacity: 0.201; } .chart .d, .chart .g { opacity: 0.7; } .chart .d { fill: url(#c); } .chart .e, .chart .h, .chart .k { fill: none; } .chart .e { stroke: #a3a0fb; } .chart .e, .chart .f, .chart .h, .chart .i { stroke-width: 2px; } .chart .f, .chart .i { fill: #fff; } .chart .f { stroke: #a4a1fb; } .chart .g { fill: url(#e); } .chart .h { stroke: #54d8ff; } .chart .i { stroke: #55d8fe; } .chart .j { stroke: none; } |
Source code of JavaScript
JavaScript is a dynamic language. We use this language for adding functionality to our web pages. Again create a file of JavaScript and then paste this code into your created file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
document.addEventListener('DOMContentLoaded', function(){ let requiredInput = document.querySelectorAll('input[required]'); let signUpButton = document.querySelector('#sign-up-button'); var checkValidForm = () => { if ( _.every(requiredInput, (input) => { return !_.isEmpty(input.value) }) ){ if (signUpButton.hasAttribute('disabled')) return signUpButton.removeAttribute('disabled') } else { if (!signUpButton.hasAttribute('disabled')) return signUpButton.addAttribute('disabled') } } _.forEach(requiredInput, (input) => { input.addEventListener('change', function(e){ console.log(e.target.value) checkValidForm() }) }) }); |
Download source code
If you are unable to copy this code and run the file, then we have created a file and in this file all the files of HTML, CSS, and JavaScript are present. Just download this file from the below download button and then you will be able to run this sign-up form.
Task:
It was the summary of creating a sign-up form using HTML, CSS, and javascript. Now I am assigning you some tasks and then you will learn more about forms. Add two new input fields in this form. Then create a text button for forgot password. Apply the hover effect on a button using CSS. Then change the background as well.
I hope you have liked this post and you have learned a lot from this post. If so, then like and share this post.
Thanks for reading this article.
Download Source CodeClick to Download