What's new

Welcome to the forum 👋, Visitor

To access the forum content and all our services, you must register or log in to the forum. Becoming a member of the forum is completely free.

Need help with basic HTML login form

Psychzor

New member
Joined
Nov 18, 2022
Messages
2
Reaction score
0
Hi there! 🤪

So i had this figured out some years back, but i cant seem to find the tutorial again or any backup.
Basically it was a simple login form that sends the user to a specified URL if the text is correct.

Something like if input type text is "custom text" and input type password is "custom text" then input type submit button go to ahref "custom url"

Code:
<div>
    <label for="username">Username:</label>
    <input type="text" id="username" name="username">
</div>
<p></p>
<div>
    <label for="pass">Password:</label>
    <input type="password" id="pass" name="password" minlength="8" required="">
</div>

<input type="submit" value="Sign in">

Funny because it was so basic and had no fancy CSS or javascript if I remember correctly. Again, I used it years go, can't really remember it properly.
So it doesn't use any database or any other advanced stuff (for me), It used to work with more names and passwords, not just one, like demo name and demo pass.

Think of it as a simple webpage locked with a password, if you want to access it, enter password, a custom word, if the word is correct, the button sends you to a custom url.

I'm just gonna leave this here and hopefully you can help.

Thanks!
 
Last edited:
My apoligies! It does involves some javascript.

Haven't stopped looking and i solved it, i guess, maybe it helps anyone who comes across same trouble as me so i'm just gonna post it.

Its rough around the edges, so no CSS but worth it.

Code:
<html>
<head>

<title>Javascript Login Form Validation</title>
<!-- Include CSS File Here -->
<link rel="stylesheet" href="css/style.css"/>
<!-- Include JS File Here -->
<script src="js/login.js"></script>
</head>
<body>
<div class="container">
<div class="main">
<form id="form_id" method="post" name="myform">
<label>USER:</label>
<input type="text" name="username" id="username"/>
<label>PASS:</label>
<input type="password" name="password" id="password"/>
<input type="button" value="LOGIN" id="submit" onclick="validate()"/>
</form>

<br>
<br>
username is <b>asd</b> and password is <b>123</b>

</div>
</div>
</body>
</html>
 
  !?####HE JS (JAVASCRIPT) BELOW
 
 
<head>
<script>
    
    var attempt = 4; // Variable to count number of attempts.
// Below function Executes on click of login button.
function validate(){
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
if ( username == "asd" && password == "123"){
alert ("Login successfully");
window.location = "success.html"; // Redirecting to other page.
return false;
}
else{
attempt --;// Decrementing by one.
alert("You have left "+attempt+" attempt;");
// Disabling fields after 3 attempts.
if( attempt == 0){
document.getElementById("username").disabled = true;
document.getElementById("password").disabled = true;
document.getElementById("submit").disabled = true;
return false;
}
}
}
    
    </script>
    </head>
 
Last edited:

Theme customization system

You can customize some areas of the forum theme from this menu.

  • Wide/Narrow view

    You can control a structure that you can use to use your theme wide or narrow.

    Grid view forum list

    You can control the layout of the forum list in a grid or ordinary listing style structure.

    Picture grid mode

    You can control the structure where you can open/close images in the grid forum list.

    Close sidebar

    You can get rid of the crowded view in the forum by closing the sidebar.

    Fixed sidebar

    You can make it more useful and easier to access by pinning the sidebar.

    Close radius

    You can use the radius at the corners of the blocks according to your taste by closing/opening it.

  • Choose the color combination that reflects your taste
    Background images
    Color gradient backgrounds
Back