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:
This is the Target Page:
Username: username
Password: password
Direction:
First Step: Kindly copy this code into the
BODY tag of your Login Page.
<script language="javascript">
function loginPage(form) {
if (form.userName.value=="username") {
if (form.passWord.value=="password") {
location="home.html"
} else {
alert("Incorrect detail Password")
}
} else { alert("Incorrect detail Username")
}
}
</script>
<table cellpadding="5" cellspacing="5">
<h1 style="text-align:center;">
Login
<input type="text" name="userName" autofocus="autofocus" style="font-size:18px; text-indent:5px;" placeholder="Enter your Username">
<input type="password" name="passWord" autofocus="autofocus" style="font-size:18px; text-indent:5px;" placeholder="Enter your Password">
<td colspan="3" style="text-align:center;">
<input type="button" value="Login" onClick="loginPage(this.form)" style="margin-right:20px; border-radius:4px; background-color:skyblue; font-size:18px; cursor:pointer;">
<input type="reset" value="Reset" style="font-size:18px; cursor:pointer; border-radius:4px; background-color:orange;">
Second Step: This source code below is simple Target Page. You can change or make one of your Target Page.
<!DOCTYPE html>
This is the next page.
<h1 style="text-align:center;">
Welcome!!! You're here.
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.