Professional Documents
Culture Documents
PROGRAMMING
LAB ASSIGNMENT - 2
SLOT: L27+L28
FACULTY: SRIDHAR RAJ S
Submitted By
Sri Shreya Volety: 19BCB0036
Write a program to demonstrate the concept of HTML, CSS and JavaScript for any
application of your choice. Create a homepage (add details about the application/your
personal details) containing the tabs to toggle between the other pages (registration,
login pages).
b. Apply CSS styles including selectors, box models, customized background - borders-
text effects, multiple columns layout, etc.,
c. Use JavaScript to validate the fields like name, e-mail, mobile number, etc., in the
registration and login pages.
Homepage: The homepage allows the user to toggle between login and registration
pages, and the registration form will be in the following pages. The validation done for
the form, is based on the javascript validation, and the regular expression variables
passed for the same. The CSS for the index page uses grid displays, box models and
sizing, imported fonts, and hover effects, for the buttons and links.
Output:
Code ( all the comments are in bold):
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PlacementStudio</title>
</head>
<body>
<!-- header content -->
<header class="container header">
<!-- navbar content -->
<nav class="nav">
<div class="logo">
<h2>PlacementStudio</h2>
</div>
<ul class="nav_menu_list">
<li class="nav_menu_item">
<a href="#" class="nav_menu_link">Login</a>
</li>
<li class="nav_menu_item">
<a href="form.html" class="nav_menu_link">Registration</a>
</li>
</ul>
</div>
<div class="btn_wrapper">
<button class="btn view_more_btn">
Login <i class="ri-arrow-right-line"></i>
</button>
<footer></footer>
</body>
</html>
CSS:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="form.css">
<script src="form.js"></script>
<title>Registration</title>
</head>
<body>
<!-- header -->
<header class="container header">
<div class="con-header">
<!-- navbar -->
<nav class="nav">
<div class="logo">
<h2>PlacementStudio</h2>
</div>
<ul class="nav_menu_list">
<li class="nav_menu_item">
<a href="#" class="nav_menu_link">Login</a>
</li>
<li class="nav_menu_item">
<a href="#" class="nav_menu_link">Registration</a>
</li>
</ul>
</div>
</nav>
</div>
</header>
<div id="main">
<div class="h-tag">
<h2>Create Your Account</h2>
</div>
<!-- create account div -->
<div class="login">
<table cellspacing="2" align="center" cellpadding="8" border="0">
<tr>
<td align="right">Enter First Name :</td>
<td><input type="text" placeholder="Enter First Name here" id="t1" class="tb"
/></td>
</tr>
<tr>
<td align="right">Enter Last Name :</td>
<td><input type="text" placeholder="Enter Last Name here" id="t2" class="tb"
/></td>
</tr>
<tr>
<td align="right">Enter Phone Number :</td>
<td><input type="text" placeholder="Enter Phone Number here" id="t3"
class="tb" /></td>
</tr>
<tr>
<td align="right">Enter Registration Number :</td>
<td><input type="text" placeholder="Enter Registration Number here" id="t4"
class="tb" /></td>
</tr>
<tr>
<td align="right">Enter Year of Graduation :</td>
<td><input type="text" placeholder="Enter Year of Graduation here" id="t5"
class="tb" /></td>
</tr>
<tr>
<td align="right">Upload Resume :</td>
<td><input type="file" id="t6" class="tb" /></td>
</tr>
<tr>
<td align="right">Enter Email ID :</td>
<td><input type="text" placeholder="Enter Email ID here" id="t7" class="tb"
/></td>
</tr>
<tr>
<td align="right">Enter Username :</td>
<td><input type="text" placeholder="Enter Username here" id="t8" class="tb"
/></td>
</tr>
<tr>
<td align="right">Enter Password :</td>
<td><input type="password" placeholder="Enter Password here" id="t9"
class="tb" /></td>
</tr>
<tr>
<td align="right">Enter Confirm Password :</td>
<td><input type="password" placeholder="Enter Password here" id="t10"
class="tb" /></td>
</tr>
<tr>
<td></td>
<td>
<input type="reset" value="Clear Form" onclick="clearFunc()" id="res"
class="btn" />
<input type="submit" value="Create Account" class="btn" onclick="registration()"
/></td>
</tr>
</table>
</div>
</div>
<footer></footer>
</body>
</html>
CSS:
@import .header {
url("https://fonts.googleapis.com/css2?famil height: var(--fixed-header-height);
y=Inter:wght@400;500&display=swap"); padding: 0 1.7rem;
}
:root {
--primary-color: #9910e9; .nav {
--link-color: #506690; width: 100%;
--btn-hover-color: #9910e9; height: 100%;
--lg-heading: #161c2d; display: flex;
--text-content: #869ab8; align-items: center;
--fixed-header-height: 4.5rem; justify-content: space-between;
} }
/*making sure to reset exisitng html .logo h2 {
formatting */ font-size: 28px;
body { color: #fff;
width: 100%; }
height: 100vh;
overflow-x: hidden; .nav_menu_list {
background-color: #ffffff; display: flex;
} align-items: center;
ul li { }
list-style-type: none; .nav_menu_list .nav_menu_item {
} margin: 0 2rem;
a{ }
text-decoration: none; .nav_menu_item .nav_menu_link {
} font-size: 16.5px;
button { line-height: 27px;
background-color: transparent; color: #fff;
border: none; text-transform: capitalize;
outline: none; letter-spacing: 0.5px;
cursor: pointer; }
}
/* body css for whole page */
/* header style */ body
.con-header{ {
margin: 0; margin:0px;
padding-left: 50px; background-color:#9910e9;
padding-right: 50px;
box-sizing: border-box; color:#f9fcf5;
font-family: "Inter", sans-serif; font-family: "Inter", sans-serif;
} }
outline:none;
#main{ border-left:5px solid #fff;
width:600px; }
height:auto;
/* css code for button*/
padding-bottom:20px; #main .btn{
margin-left:auto; width:150px;
margin-right:auto; height:32px;
border-radius:5px; outline:none;
padding-left:10px; color:#fff;
margin-top:10px; font-weight:bold;
border-top:3px double #fff; border:0px solid #9910e9;
border-bottom:3px double #fff; text-shadow: 0px 0.5px 0.5px #fff;
padding-top:0px; border-radius: 2px;
} font-weight: 600;
color: #9910e9;
#main table{ letter-spacing: 1px;
font-family: "Inter", sans-serif; font-size:14px;
} background-color:#fff;
/* css code for textbox */ -webkit-transition: 1s;
-moz-transition: 1s;
#main .tb{ transition: 1s;
height:28px; }
width:230px;
border:1px solid #9910e9; #main .btn:hover{
color:#9910e9; background-color:#9910e9;
font-weight:bold; outline:none;
border-left:5px solid #fff; border-radius: 2px;
opacity:0.9; color:#fff;
} border:1px solid #fff;
-webkit-transition: 1s;
#main .tb:focus{ -moz-transition: 1s;
height:28px; transition: 1s;
border:1px solid #9910e9; }
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="form.css">
<title>Login</title>
</head>
<body>
<!-- header -->
<header class="container header">
<div class="con-header">
<!-- navbar -->
<nav class="nav">
<div class="logo">
<h2>PlacementStudio</h2>
</div>
<ul class="nav_menu_list">
<li class="nav_menu_item">
<a href="#" class="nav_menu_link">Login</a>
</li>
<li class="nav_menu_item">
<a href="#" class="nav_menu_link">Registration</a>
</li>
</ul>
</div>
</nav>
</div>
</header>
<!-- Main div code -->
<div id="main">
<div class="h-tag">
<h2>Login</h2>
</div>
<!-- login div -->
<div class="login">
<table cellspacing="2" align="center" cellpadding="8" border="0">
<tr>
<td align="right">Enter Username :</td>
<td><input type="text" placeholder="Enter Username here" id="t8" class="tb"
/></td>
</tr>
<tr>
<td align="right">Enter Password :</td>
<td><input type="password" placeholder="Enter Password here" id="t9"
class="tb" /></td>
</tr>
<tr>
<td align="right">Confirm Password :</td>
<td><input type="password" placeholder="Enter Password here" id="t10"
class="tb" /></td>
</tr>
<tr>
<td></td>
<td>
</div>
<footer></footer>
</body>
</html>
Output:
Successful Submission:
Validation for empty fields:
if(fname=='')
{
alert('Please enter your first name');
}
else if(!letters.test(fname))
{
alert('Name field required only alphabet characters');
}
else if(lname=='')
{
alert('Please enter your last name');
}
else if(!letters.test(lname))
{
alert('Name field required only alphabet characters');
}
else if(phone=='')
{
alert('Please enter your phone no.');
}
else if (!ph.test(phone).value)
{
alert('Invalid phone');
}
else if(rno=='')
{
alert('Please enter your registration no.');
}
else if (!regno.test(rno))
{
alert('Invalid registration no.');
}
else if(year=='')
{
alert('Please enter your graduation year');
}
else if (year>2023)
{
alert('Year of Graduation cannot be after 2023');
}
else if(email=='')
{
alert('Please enter your user email id');
}
else if (!filter.test(email))
{
alert('Invalid email');
}
else if(uname=='')
{
alert('Please enter the user name.');
}
else if(!letters.test(uname))
{
alert('User name field required only alphabet characters');
}
else if(pwd=='')
{
alert('Please enter Password');
}
else if(cpwd=='')
{
alert('Enter Confirm Password');
}
else if(!pwd_expression.test(pwd))
{
alert ('Upper case, Lower case, Special character and Numeric letter are
required in Password filed');
}
else if(pwd != cpwd)
{
alert ('Password not Matched');
}
else if(document.getElementById("t9").value.length < 6)
{
alert ('Password minimum length is 6');
}
else if(document.getElementById("t9").value.length > 12)
{
alert ('Password max length is 12');
}
else
{
alert('Thank You for creating an account!');
// Redirecting to other page or webste code.
window.location = "http://www.campuslife.co.in";
}
}
function clearFunc()
{
document.getElementById("t1").value="";
document.getElementById("t2").value="";
document.getElementById("t3").value="";
document.getElementById("t4").value="";
document.getElementById("t5").value="";
document.getElementById("t6").value="";
document.getElementById("t7").value="";
document.getElementById("t8").value="";
document.getElementById("t9").value="";
document.getElementById("t10").value="";
}