First, make an HTML file with a name like program.html:
<html>
<head>
<title>
Login page in java Script
</title>
<script src="script.js">
</script>
</head>
<body bgcolor="Brown">
<center><font size="8" scolor="white"> Simple Login Page In Java Script</font>
</center>
<br><br><br><br><br><br>
<center>
<font size="5" color="white"> Enter User Name:</font> <input type="text" size="30" id="name" >
<br>
<font size="5" color="white"> Enter Password: </font> <input type="password" size="30" id="pass" >
<br>
<br><br>
<button onclick="Login()"> Submit </button>
</center>
</body>
</html>
.........................................................................................................................
Then, make a file in the same directory with a name like script.js:
function Login() {
var user=document.getElementById("name").value;
var pass=document.getElementById("pass").value;
if(user==='')
{
document.writeln("<font size='8' >Missing User Name, </font>");
}
if(pass==='')
{
document.writeln("<font size='8' >Missing Password </font>");
}
if(user.length>1&&pass.length>1){
if(user==="abdullah"&&pass==="masood"){
document.writeln("<font size='8' >Successfully Login </font>");
}
if(user!=="abdullah"||pass!=="masood"){
document.writeln("<font size='8' >NO Correct </font>");
}
}
}
<html>
<head>
<title>
Login page in java Script
</title>
<script src="script.js">
</script>
</head>
<body bgcolor="Brown">
<center><font size="8" scolor="white"> Simple Login Page In Java Script</font>
</center>
<br><br><br><br><br><br>
<center>
<font size="5" color="white"> Enter User Name:</font> <input type="text" size="30" id="name" >
<br>
<font size="5" color="white"> Enter Password: </font> <input type="password" size="30" id="pass" >
<br>
<br><br>
<button onclick="Login()"> Submit </button>
</center>
</body>
</html>
.........................................................................................................................
Then, make a file in the same directory with a name like script.js:
function Login() {
var user=document.getElementById("name").value;
var pass=document.getElementById("pass").value;
if(user==='')
{
document.writeln("<font size='8' >Missing User Name, </font>");
}
if(pass==='')
{
document.writeln("<font size='8' >Missing Password </font>");
}
if(user.length>1&&pass.length>1){
if(user==="abdullah"&&pass==="masood"){
document.writeln("<font size='8' >Successfully Login </font>");
}
if(user!=="abdullah"||pass!=="masood"){
document.writeln("<font size='8' >NO Correct </font>");
}
}
}