INDEX Merged
INDEX Merged
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
11.
12.
EXPERIMENT 03
AIM - Add validations to the site for registration, user login, user profile and
payment by credit card using Java Script
USING HTML-
<!DOCTYPE html>
<html lang="en"><head>
<meta charset="utf-8">
<title>JavaScript Form Validation using a sample registration form</title>
<meta name="keywords" content="example, JavaScript Form Validation, Sample
registration form" />
<meta name="description" content="This document is an example of JavaScript Form
Validation using a sample registration form. " />
<link rel='stylesheet' href='js-form-validation.css' type='text/css' />
<script src="sample-registration-form-validation.js"></script>
</head>
<body onload="document.registration.userid.focus();">
<h1>Registration Form</h1>
Use tab keys to move from one input field to the next.
<form name='registration' onSubmit="return formValidation();">
<ul>
<li><label for="userid">User id:</label></li>
<li><input type="text" name="userid" size="12" /></li>
<li><label for="passid">Password:</label></li>
<li><input type="password" name="passid" size="12" /></li>
<li><label for="username">Name:</label></li>
<li><input type="text" name="username" size="50" /></li>
<li><label for="address">Address:</label></li>
<li><input type="text" name="address" size="50" /></li>
<li><label for="country">Country:</label></li>
<li><select name="country">
<option selected="" value="Default">(Please select a country)</option>
<option value="AF">Australia</option>
<option value="AL">Canada</option>
<option value="DZ">India</option>
<option value="AS">Russia</option>
<option value="AD">USA</option>
</select></li>
<li><label for="zip">ZIP Code:</label></li>
<li><input type="text" name="zip" /></li>
<li><label for="email">Email:</label></li>
<li><input type="text" name="email" size="50" /></li>
<li><label id="gender">Sex:</label></li>
<li><input type="radio" name="msex" value="Male" /><span>Male</span></li>
<li><input type="radio" name="fsex" value="Female"
/><span>Female</span></li>
<li><label>Language:</label></li>
<li><input type="checkbox" name="en" value="en" checked
/><span>English</span></li>
<li><input type="checkbox" name="nonen" value="noen" /><span>Non
English</span></li>
<li><label for="desc">About:</label></li>
<li><textarea name="desc" id="desc"></textarea></li>
<li><input type="submit" name="submit" value="Submit" /></li>
</ul>
</form>
</body>
</html>
USING JAVA SCRIPT
function formValidation()
{
var uid = document.registration.userid;
var passid = document.registration.passid;
var uname = document.registration.username;
var uadd = document.registration.address;
var ucountry = document.registration.country;
var uzip = document.registration.zip;
var uemail = document.registration.email;
var umsex = document.registration.msex;
var ufsex = document.registration.fsex;
if(userid_validation(uid,5,12))
{
if(passid_validation(passid,7,12))
{
if(allLetter(uname))
{
if(alphanumeric(uadd))
{
if(countryselect(ucountry))
{
if(allnumeric(uzip))
{
if(ValidateEmail(uemail))
{
if(validsex(umsex,ufsex))
{
}
}
}
}
}
}
}
}
return false;
} function userid_validation(uid,mx,my)
{
var uid_len = uid.value.length;
if (uid_len == 0 || uid_len>= my || uid_len< mx)
{
alert("User Id should not be empty / length be between "+mx+" to "+my);
uid.focus();
return false;
}
return true;
}
function passid_validation(passid,mx,my)
{
var passid_len = passid.value.length;
if (passid_len == 0 ||passid_len>= my || passid_len< mx)
{
alert("Password should not be empty / length be between "+mx+" to "+my);
passid.focus();
return false;
}
return true;
}
function allLetter(uname)
{
var letters = /^[A-Za-z]+$/;
if(uname.value.match(letters))
{
return true;
}
else
{
alert('Username must have alphabet characters only');
uname.focus();
return false;
}
}
function alphanumeric(uadd)
{
var letters = /^[0-9a-zA-Z]+$/;
if(uadd.value.match(letters))
{
return true;
}
else
{
alert('User address must have alphanumeric characters only');
uadd.focus();
return false;
}
}
function countryselect(ucountry)
{
if(ucountry.value == "Default")
{
alert('Select your country from the list');
ucountry.focus();
return false;
}
else
{
return true;
}
}
function allnumeric(uzip)
{
var numbers = /^[0-9]+$/;
if(uzip.value.match(numbers))
{
return true;
}
else
{
alert('ZIP code must have numeric characters only');
uzip.focus();
return false;
}
}
function ValidateEmail(uemail)
{
var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if(uemail.value.match(mailformat))
{
return true;
}
else
{
alert("You have entered an invalid email address!");
uemail.focus();
return false;
}
} function validsex(umsex,ufsex)
{
x=0;
if(umsex.checked)
{
x++;
} if(ufsex.checked)
{
x++;
}
if(x==0)
{
alert('Select Male/Female');
umsex.focus();
return false;
}
else
{
alert('Form Succesfully Submitted');
window.location.reload()
return true;
}
}
EXPERIMENT 04
Index.Html:
<!DOCTYPE html>
<html>
<head>
<title>Password Validation Form</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Quantum Login page</h1>
<form id="password-form">
<label for="uname">Q-ID:</label>
<input type="text" id="uname" name="Q-ID"><br><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password"><br><br>
<label for="confirm-password">Confirm Password:</label>
<input type="password" id="confirm-password" name="confirm-
password"><br><br>
<button type="submit" onclick="op()">Login</button>
<p id="error-message"></p>
</form>
<script src="script.js"></script>
</body>
</html>
Style.css:
body {
font-family: Arial, sans-serif;
background-image: url('header_image.jpg');
background-repeat: no-repeat;
background-size: 1600px 900px;
}
#password-form {
width: 50%;
margin: 40px auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
label {
display: block;
margin-bottom: 10px;
}
input[type="password"] {
width: 100%;
padding: 10px;
margin-bottom: 20px;
border: 1px solid #ccc;
}
input[type="text"] {
width: 100%;
padding: 10px;
margin-bottom: 20px;
border: 1px solid #ccc;
}
button[type="submit"] {
background-color: #4CAF50;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
}
button[type="submit"]:hover {
background-color: #a50707;
}
#error-message {
color: red;
}
Script.js:
const passwordForm = document.getElementById('password-form');
const passwordInput = document.getElementById('password');
const confirmPasswordInput = document.getElementById('confirm-
password');
const errorMessage = document.getElementById('error-message');
if (password.length < 8) {
errorMessage.textContent = 'Password must be at least 8 characters
long.';
return;
}
if (!/[A-Z]/.test(password)) {
errorMessage.textContent = 'Password must contain at least one
uppercase letter.';
return;
}
if (!/[a-z]/.test(password)) {
errorMessage.textContent = 'Password must contain at least one
lowercase letter.';
return;
}
if (!/[0-9]/.test(password)) {
errorMessage.textContent = 'Password must contain at least one
number.';
return;
}
errorMessage.textContent = '';
alert('Redirecting you to our Page');
});
function op(){
var field2=document.getElementById("password").value;
if(field2==="Vikrant@123")
window.location="quantum.html";
else{
alert("invaild information")
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Quantum</title>
</head>
<body>
<style type="text/css">
h1{background-color:rgb(248, 3, 3)}
h4{background-color:yellow ;}
table{ background-color:aqua;}
</style>
<h1><left><Font color="white" Font size="30px" font face="Imprint
MT
Shadow"><center>QUANTUM UNIVERSITY</center>
<MARQUEE>
The Future isexciting...
</MARQUEE>
</Font></left></h1>
<h5><u><b><font color=" RED"><font size=10px><i>QUANTUM
UNIVERSITY</i></font></font></b></u></h5>
<h4><Center><b><font color="blue"><font
size="5px"><marquee>ADMISSION
OPEN FOR SESSION 2023-24<a
href="https://www.quantumuniversity.edu.in">
Click Here
</a></marquee></font></b></Center></h4>
<p>
<b><font color=" GREEN"><font size=5PX>
Quantum University is a private university in Uttarakhand, India.
The University was earlier known as Quantum Global Campus
Roorkee.
The University campus is located in the town of Roorkee with its
corporate office in Dehradun.Quantum University,Roorkee, Uttarakhand
has 129 Courses with Average Fees 1,04000 per year.
Top Courses at Quantum University Roorkee, Uttarakhand.
</font></font></b>
</p>
<H3><font color="BLUE"><b><font size ="05"> <center> <U>
"QUANTUM UNIVERSITY HIGHLIGHTS"
</U></center></font></b></font></H3>
<center>
<table border="all side" cellspacing="10" cellpadding="15" bg color=
"orange">
<tr>
<td>year of establishment</td>
<td>2017</td>
</tr>
<tr>
<td>Campus
<td>Roorkee</td>
</tr>
<tr><td>Campus size</td>
<td>30 acre</td>
</tr>
<tr>
<td> Recognised by </td>
<td> UGC</td>
</tr>
<tr>
<td>College rankings </td>
<td> Ranked 60 for MBA by Times 2020
Ranked 73 for Engineering by Times 2019
Ranked 98 for Private MBA by Week 2019
</td>
</tr>
<tr>
<td> Modes of education </td>
<td> Online, full-time, distance learning </td>
</tr>
<tr>
<td> Number of courses offered </td>
<td>124 courses across 14 streams</td>
</tr>
<tr>
<td> No. of Scholarships </td>
<td> 3 types of scholarships </td>
</tr>
<tr>
<td> Highest salary offered (2023) </td>
<td> 33.5 Lakh </td>
</tr>
<tr>
<td> Official website </td>
<td> quantumuniversity.edu.in </td>
</tr>
<tr>
<td>Gender intake </td>
<td> Co-education</td>
</tr>
<tr>
<td>Application mode (when admission are open) </td>
<td>Online, Offline and One to One</td>
</tr>
</table>
</center>
</body>
</html>
Experiment - 5
AIM - Design the Static Web Site or pages using HTML and DHTML for
Quantum University.
1. Index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quantum University - Home</title>
<link rel="stylesheet" href="styles.css"> <!-- Optional CSS link -->
<script src="script.js" defer></script> <!-- JavaScript link -->
</head>
<body>
<header>
<h1>Quantum University</h1>
<nav>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About Us</a></li>
<li><a href="departments.html">Departments</a></li>
<li><a href="courses.html">Courses</a></li>
<li><a href="contact.html">Contact Us</a></li>
</ul>
</nav>
</header>
<main>
<h2>Welcome to Quantum University</h2>
<p>Explore our programs, departments, and more.</p>
</main>
<footer>
<p>© 2024 Quantum University</p>
</footer>
</body>
</html>
2. styles.css
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
header {
background-color: #0044cc;
color: white;
padding: 15px;
text-align: center;
}
nav ul {
list-style-type: none;
padding: 0;
}
nav ul li {
display: inline;
margin: 0 10px;
}
nav ul li a {
color: white;
text-decoration: none;
}
nav ul li a:hover {
text-decoration: underline;
}
main {
padding: 20px;
}
footer {
background-color: #0044cc;
color: white;
text-align: center;
padding: 10px;
position: fixed;
bottom: 0;
width: 100%;
}
3. script.js:
document.addEventListener("DOMContentLoaded", function() {
const welcomeMessage = document.createElement("p");
welcomeMessage.textContent = "Enjoy exploring Quantum University!";
welcomeMessage.style.color = "#0044cc";
document.querySelector("main").appendChild(welcomeMessage);
});
OUTPUT:
EXPERIMENT - 6
AIM - Design the dynamic web site or pages using xml, JavaScript and
servlet for quantum university.
You'll need a web server (e.g., Apache Tomcat), a text editor or Integrated
Development Environment (IDE), and a database system (e.g., MySQL) to
store university data.
Create Java Servlets to handle HTTP requests and interact with the
database. Below is a simplified example of a Servlet to fetch course
information:
```java
@WebServlet("/CourseServlet")
public class CourseServlet extends HttpServlet
{
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
{
// Fetch data from the database and convert it to XML
String courseXML = fetchCourseDataFromDatabase();
out.write(courseXML);
}
Design XML templates for various pages. For example, you can create an
XML template for displaying course information:
```xml
<course>
<title>Course Title</title>
<description>Course Description</description>
<instructor>Instructor Name</instructor>
<!-- Add more course details here -->
</course>
```
```html
<script>
function loadCourseData() {
var xhr = new XMLHttpRequest();
xhr.open("GET", "CourseServlet", true);
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 &&xhr.status === 200) {
var courseData = xhr.responseXML;
// Use JavaScript to parse and display the course data in the
HTML
document.getElementById("courseTitle").innerHTML =
courseData.querySelector("title").textContent;
document.getElementById("courseDescription").innerHTML =
courseData.querySelector("description").textContent;
// Update other elements as needed
}
};
xhr.send();
}
window.onload = function() {
loadCourseData();
};
</script>
```
Design your HTML pages and include the JavaScript code for dynamic
content. Here's a simple example of an HTML page that displays course
information:
html
<!DOCTYPE html>
<html>
<head>
<title>Quantum University</title>
</head>
<body>
<h1>Course Information</h1>
<div id="courseTitle"></div>
<div id="courseDescription"></div>
<!-- Add more HTML elements as needed -->
</body>
</html>
```
Deploy your web application to your web server and access it through a
web browser.
To convert static web pages into dynamic web pages using Servlets and
cookies, you first need to set up and configure the Apache Tomcat web
server. Here are the steps to install and configure Tomcat:
Tomcat should start, and you can access the default Tomcat page by
opening a web browser and navigating to `http://localhost:8080`.
You can configure Tomcat further by editing the configuration files in the
`conf` directory. Common configuration files include `server.xml`,
`web.xml`, and `context.xml`. These files allow you to set up connectors,
configure default web applications, and more.
Now, to convert static web pages into dynamic ones using Servlets and
cookies, follow these steps:
```java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
```xml
<servlet>
<servlet-name>myServlet</servlet-name>
<servlet-class>MyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>myServlet</servlet-name>
<url-pattern>/myservlet</url-pattern>
</servlet-mapping>
```
Modify your static web pages (HTML, JSP, etc.) to include references to
your Servlets. For example, you can use AJAX to fetch dynamic data
from the Servlet and update the content.
```java
Cookie cookie = new Cookie("username", "JohnDoe");
response.addCookie(cookie);
You can create an XML document that represents the information for 20
students. Here's an example of what the XML document might look like:
```xml
<university>
<student>
<roll_number>101</roll_number>
<name>John Doe</name>
<marks>
<subject>Math</subject>
<score>90</score>
</marks>
<marks>
<subject>Physics</subject>
<score>85</score>
</marks>
<marks>
<subject>Chemistry</subject>
<score>78</score>
</marks>
<marks>
<subject>Biology</subject>
<score>92</score>
</marks>
<marks>
<subject>English</subject>
<score>88</score>
</marks>
<total>433</total>
<percentage>86.6</percentage>
</student>
<!-- Add data for 19 more students -->
</university>
```
You can save this XML document on your server, ensuring it's accessible
by your program.
Here's a Java program that reads the XML document and retrieves a
student's information based on their roll number:
```java
import org.w3c.dom.*;
import javax.xml.parsers.*;
import java.io.*;
import org.xml.sax.SAXException;
if (rollNumber.equals(targetRollNumber)) {
a. **Google Maps:** Obtain a Google Maps API key from the Google
Developers Console. Integrate maps and geolocation features into your
website.
Design a web form for user registration. Use HTML to create form fields
(e.g., name, email, password) and apply client-side validation with
JavaScript to ensure data consistency.
Utilize AJAX to submit the registration form data to the server without
refreshing the entire page, providing a seamless user experience. Make
AJAX requests to the server for user registration and data retrieval.
Use JavaScript to update the website's content with data from web
services, the database, and other sources in real-time without needing to
refresh the page.