Assignment 2
Assignment 2
1 22BDS0233
TASK 1
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Number Sorter</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
background-color: rgb(201, 189, 212);
}
label {
display: block;
margin-bottom: 5px;
background-color: rgb(130, 161, 109);
}
input[type="number"] {
width: 100px;
margin-bottom: 10px;
}
button {
padding: 10px 20px;
margin-right: 10px;
cursor: pointer;
}
#output {
margin-top: 20px;
}
</style>
</head>
<body>
<h3>Input section</h3>
<label>Enter numbers:</label>
<input type="number" id="num1">
<input type="number" id="num2">
<input type="number" id="num3">
<!-- Add more input fields as needed -->
<div id="output"></div>
<script>
function sortAscending() {
var nums = [];
nums.push(parseFloat(document.getElementById('num1').value));
nums.push(parseFloat(document.getElementById('num2').value));
nums.push(parseFloat(document.getElementById('num3').value));
// Add more numbers as needed
function sortDescending() {
var nums = [];
nums.push(parseFloat(document.getElementById('num1').value));
nums.push(parseFloat(document.getElementById('num2').value));
nums.push(parseFloat(document.getElementById('num3').value));
// Add more numbers as needed
</body>
</html>
TASK2
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>multi task</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: justify;
}
#result {
margin-top: 20px;
}
input[type="number"] {
padding: 8px;
margin: 10px;
}
button {
padding: 10px 20px;
background-color: #739ed2;
color: #fff;
border: none;
cursor: pointer;
}
#result {
margin-top: 20px;
}
</style>
</head>
<body>
<div id="result"></div>
<script>
function calculate() {
var num1 = parseFloat(document.getElementById('num1').value);
var num2 = parseFloat(document.getElementById('num2').value);
var num3 = parseFloat(document.getElementById('num3').value);
document.getElementById('result').innerHTML =
'Maximum: ' + max + '<br>' +
'Ascending: ' + ascending.join(', ') + '<br>' +
'Descending: ' + descending.join(', ');
}
</script>
<h2>Speed Checker</h2>
<script>
function checkSpeed() {
var speed = document.getElementById("speedInput").value;
var penaltyPoints = 0;
<script>
function checkOddOrEven() {
var number = document.getElementById("numberInput").value;
var resultElement = document.getElementById("result");
if (number % 2 === 0) {
resultElement.textContent = number + " is an even number.";
} else {
resultElement.textContent = number + " is an odd number.";
}
}
</script>
</body>
</html>
TASK 3
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Event Management</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
background-color: rgb(201, 189, 212);
text-decoration: aqua;
}
</style>
</head>
<body>
<h1>Welcome to Event Management Website</h1>
<a href="login.html">Login</a>
<a href="event.html">Event Registration</a>
</body>
</html>
LOGIN.HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Login</title>
<script src="login_validation.js" defer></script>
<style>
body{
font-family: Arial, sans-serif;
margin: 20px;
background-color: rgb(201, 189, 212);
text-decoration: rgb(97, 133, 133);
}
</style>
</head>
<body>
<h2>Login</h2>
<form id="loginForm" onsubmit="return validateLoginForm()">
Username: <input type="text" id="username" name="username"><br>
Password: <input type="password" id="password"
name="password"><br>
<button type="submit">Login</button>
</form>
</body>
</html>
login_validation.js
function validateLoginForm() {
var username = document.getElementById('username').value;
var password = document.getElementById('password').value;
return true}
event.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Event Registration</title>
<script src="event_registration_validation.js" defer></script>
<script>
function validateForm() {
var firstName = document.forms["registrationForm"]
["first_name"].value;
var lastName = document.forms["registrationForm"]
["last_name"].value;
var password = document.forms["registrationForm"]
["password"].value;
var confirmPassword = document.forms["registrationForm"]
["confirm_password"].value;
var phone = document.forms["registrationForm"]
["phone"].value;
var email = document.forms["registrationForm"]
["email"].value;
var checkboxChecked =
document.querySelector('input[name="interests"]:checked');
if (!checkboxChecked) {
alert("Please select at least one interest");
return false;
}
return true;
}
</script>
<style>
body{
background-color: rgb(201, 189, 212);
}
</style>
</head>
<body>
<form name="registrationForm" onsubmit="return validateForm()">
First Name: <input type="text" name="first_name"><br>
Last Name: <input type="text" name="last_name"><br>
Password: <input type="password" name="password"><br>
Confirm Password: <input type="password"
name="confirm_password"><br>
Phone: <input type="text" name="phone"><br>
Email: <input type="text" name="email"><br>
Gender:
<input type="radio" name="gender" value="male"> Male
<input type="radio" name="gender" value="female"> Female<br>
Interests:
<input type="checkbox" name="interests" value="sports"> Sports
<input type="checkbox" name="interests" value="music">
Music<br>
Message: <textarea id="message"></textarea><br>
<input type="submit" value="Submit">
</form>
</head>
</html>
event_registration_calidation.js
function validateEventRegistrationForm() {