Registration Form In HTML With Javascript Validation With Source Code
The Registration Form In HTML With Javascript Validation was developed using JavaScript, CSS and HTML, In this Javascript Project With Source Code It’s all about ensuring that the form’s validation is correct. When the submit button is pressed, the project provides minimal mandatory form details that are validated. You may also utilize this validation to improve the look and functionality of your project.
A Registration Form Validation In Javascript Using Regular Expression Simply provide the user’s username, email address, password, and password confirmation. You can also confirm their validity by clicking the submit button. Furthermore, the design of this project is quite basic, so the user will have no problems working on it. These validations add credibility to the concept and make it more realistic.
This Javascript Project With Source Code also includes a downloadable Project With Source Code for free, just find the downloadable source code below and click to start downloading.
I have here a suggested list of Best JavaScript Projects with Source Code Free to download and I’m sure this can help you to improve your skills in JavaScript programming and web development as a whole.
To start executing a Registration Form In HTML With Javascript Validation With Source Code, makes sure that you have any platform in creating a JavaScript, CSS, bootstrap, and HTML installed in your computer, in my case I will use Sublime Text.
Registration Form In HTML With Javascript Validation With Source Code : Steps on how to create the project
Time needed: 5 minutes
These are the steps on how to create Registration Form In HTML With Javascript Validation With Source Code
- Step 1: Create a folder.
First, create a folder and named it.
- Step 2: Open the folder in “Sublime Text”.
Second ,after creating a folder, open it in “sublime text“.
- Step 3: Create a html file.
Third, create a “html” file and save it as “index.html“
The code given below is for the html module
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="style.css"> <title>Form validation (IT SOURCECODE)</title> </head> <body> <div class="container"> <form id="form" class="form" autocomplete="off"> <h2>Register with us</h2> <div class="form-control"> <label for="username">Username</label> <input type="text" id="username" placeholder="Enter username"> <small>Error message</small> </div> <div class="form-control"> <label for="email">Email</label> <input type="text" id="email" placeholder="Enter email"> <small>Error message</small> </div> <div class="form-control"> <label for="password">Password</label> <input type="password" id="password" placeholder="Enter password"> <small>Error message</small> </div> <div class="form-control"> <label for="password2">Confirm Passsword</label> <input type="password" id="password2" placeholder="Enter password again"> <small>Error message</small> </div> <button type="submit">Submit</button> </form> </div> <script src="app.js"></script> </body> </html>
In this module which is the html module of the simple project.
The code given below is for the css module
<style> @import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@600&display=swap'); :root{ --success-color:#2ecc71; --error-color: #e74c3c; } *{ box-sizing: border-box; } body{ background-color: #f9fafb; font-family:'Open Sans',sans-serif; display: flex; align-items: center; justify-content: center; min-height: 100vh; margin: 0; } .container{ background-color: #fff; border-radius: 5px; box-shadow: 0 2px 10px rgba(0,0,0, 0.3); width: 400px; } h2{ text-align: center; margin: 0 0 20px; } .form{ padding: 30px 40px; } .form-control{ margin-bottom: 10px; padding-bottom: 20px; position: relative; } .form-control label{ color: #777; display: block; margin-bottom: 5px; } .form-control input{ border: 2px solid #f0f0f0; border-radius: 4px; width: 100%; padding: 10px; font-size: 14px; } .form-control input:focus{ outline: 0; border-color: #777; } .form-control.success input{ border-color:var(--success-color); } .form-control.error input{ border-color:var(--error-color); } .form-control small{ color: var(--error-color); position: absolute; bottom: 0; left: 0; visibility: hidden; } .form-control.error small{ visibility: visible; } .form button{ cursor: pointer; background-color: #3498db; border: 2px sold #3498db; border-radius: 4px; color: #fff; display: block; font-size: 16px; padding: 10px; margin-top: 10px; width: 100%; } </style>
In this module which is the css module of the simple project.
The code given below is for the javascript module
<script> const form=document.getElementById('form'); const username=document.getElementById('username'); const email=document.getElementById('email'); const password=document.getElementById('password'); const password2=document.getElementById('password2'); //Show input error message function showError(input,message){ const formControl=input.parentElement; formControl.className='form-control error'; const small=formControl.querySelector('small'); small.innerText=message; } function showSuccess(input){ const formControl=input.parentElement; formControl.className='form-control success'; } //Email function isValidEmail(email) { const re= /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(String(email).toLowerCase()); } form.addEventListener('submit',function(e){ e.preventDefault(); if(username.value===''){ showError(username,'Username is required'); } else{ showSuccess(username); } if(email.value===''){ showError(email,'Email is required'); }else if(!isValidEmail(email.value)){ showError(email,'Email is not valid'); } else{ showSuccess(email); } if(password.value===''){ showError(password,'Password is required'); } else{ showSuccess(password); } if(password2.value===''){ showError(password2,'confirm password is required'); } else{ showSuccess(password2); } }); </script>
In this module which is the javascript module of the simple project.
Project Output
ABOUT PROJECT | PROJECT DETAILS |
---|---|
Project Name : | Registration Form In HTML With Javascript Validation |
Project Platform : | JavaScript |
Programming Language Used: | php,javascript,html,css |
Developer Name : | itsourcecode.com |
IDE Tool (Recommended): | Sublime |
Project Type : | Web Application |
Database: | None |
Upload Date: | July 17, 2021 |
Downloadable Source Code
Summary
This JavaScript Project With Source Code is simply in HTML, CSS, and JavaScript. To start creating this Simple Javascript Project With Source Code, make sure that you have basic knowledge in HTML, CSS and Javascript.
This Javascript Game Project also includes a downloadable Javascript Game Project With Source Code for free.
Related Articles
- Todo List In JavaScript With Source Code
- Currency Converter Project in JavaScript with Source Code
- Calculator In JavaScript Source Code
- [SOLVED] How To Make A Live Chat In JavaScript With Source Code
Inquiries
If you have any questions or suggestions about Registration Form In HTML With Javascript Validation With Source Code , please feel free to leave a comment below.