How To Create Login Form Using JavaScript

In this tutorial, we are going to learn on How To Create Login Form Using JavaScript. This is simple Login Page using a simple script. The Username is username and the Password is password. But you can change this after you download the source code below, and go to the script to make it change. Then, create a target page. This is the Login Page: login pageThis is the Target Page: target pageUsername: username Password: password

Direction:

First Step: Kindly copy this code into the BODY tag of your Login Page.
  1. <script language="javascript">
  2.  
  3. function loginPage(form) {
  4. if (form.userName.value=="username") {
  5. if (form.passWord.value=="password") {
  6. location="home.html"
  7. } else {
  8. alert("Incorrect detail Password")
  9. }
  10. } else { alert("Incorrect detail Username")
  11. }
  12. }
  13.  
  14. </script>
  1.  
  2.  
  3. <table cellpadding="5" cellspacing="5">
  4. <tr>
  5. <td colspan="3">
  6. <h1 style="text-align:center;">
  7. Login
  8. </h1>
  9. </td>
  10. </tr>
  11. <tr>
  12. <td>
  13. <h2>Username</h2>
  14. </td>
  15. <td width="10">
  16. </td>
  17. <td>
  18. <input type="text" name="userName" autofocus="autofocus" style="font-size:18px; text-indent:5px;" placeholder="Enter your Username">
  19. </td>
  20. </tr>
  21. <tr>
  22. <td>
  23. <h2>Password</h2>
  24. </td>
  25. <td width="10">
  26. </td>
  27. <td>
  28. <input type="password" name="passWord" autofocus="autofocus" style="font-size:18px; text-indent:5px;" placeholder="Enter your Password">
  29. </td>
  30. </tr>
  31. <tr>
  32. <td colspan="3" style="text-align:center;">
  33. <br />
  34. <input type="button" value="Login" onClick="loginPage(this.form)" style="margin-right:20px; border-radius:4px; background-color:skyblue; font-size:18px; cursor:pointer;">
  35. <input type="reset" value="Reset" style="font-size:18px; cursor:pointer; border-radius:4px; background-color:orange;">
  36. <br />
  37. <br />
  38. </td>
  39. </tr>
  40.  
  41. </form>
  42.  
Second Step: This source code below is simple Target Page. You can change or make one of your Target Page.
  1. <!DOCTYPE html>
  2. This is the next page.
  3. </title>
  4.  
  5. <style type="text/css">
  6. </style>
  7. </head>
  8.  
  9.  
  10. <h1 style="text-align:center;">
  11. Welcome!!! You're here.
  12. </h1>
  13.  
  14. </body>
  15.  
  16. </html>
So what can you say about this work? Share your thoughts in the comment section below or email me at [email protected]. Practice Coding. Thank you.

Comments

Submitted byRyan Bergafce (not verified)on Fri, 03/31/2023 - 21:21

LOOK, ITS A GOOD IDEA BUT NOT GOOD ENOUGH. SHOW ME THE REAL CODE, PLEASE
Submitted byHeal Lab (not verified)on Fri, 06/23/2023 - 17:25

Heal At Home

Add new comment