Webtech Akshay 16137mailvalidatoin
Webtech Akshay 16137mailvalidatoin
Theory/Concepts:
1
Batch: MCA-SPZ-CYBER-SECURITY-II-B1_Web Technologies
Detailed Steps:
1. Form Creation: Use HTML to create a form with an email
input field and a submit button.
2. Styling: Use CSS to style the form and modal popup,
ensuring they are visually appealing and responsive.
3. Email Validation: Implement JavaScript to validate the
email address format using a regular expression.
4. Modal Popup: Use JavaScript to display a modal popup with
the user's entered details upon form submission.
5. Interactive Features: Add features to close the modal
when clicking on the close button or outside the modal.
By integrating these technologies, the experiment demonstrates
how to create a functional and aesthetically pleasing web form
with real-time validation and user feedback mechanisms. This
approach ensures that users are aware of any input errors
immediately and provides a seamless interaction with the web
application.
2
Batch: MCA-SPZ-CYBER-SECURITY-II-B1_Web Technologies
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<title>User Detail Form</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.form-container {
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
text-align: center;
3
Batch: MCA-SPZ-CYBER-SECURITY-II-B1_Web Technologies
}
form h2 {
margin-top: 0;
}
label {
display: block;
margin-bottom: 5px;
}
input[type="text"],
input[type="email"],
input[type="tel"] {
width: 100%;
padding: 8px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
padding: 10px 15px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
4
Batch: MCA-SPZ-CYBER-SECURITY-II-B1_Web Technologies
}
button:hover {
background-color: #0056b3;
}
/* Modal styles */
.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0, 0, 0, 0.4);
animation: fadeIn 0.5s;
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.modal-content {
background-color: #fefefe;
margin: 15% auto;
5
Batch: MCA-SPZ-CYBER-SECURITY-II-B1_Web Technologies
padding: 20px;
border: 1px solid #888;
width: 80%;
max-width: 500px;
border-radius: 10px;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
animation: slideIn 0.5s;
color: orange; /* Change text color to orange */
}
@keyframes slideIn {
from { transform: translateY(-50px); }
to { transform: translateY(0); }
}
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
6
Batch: MCA-SPZ-CYBER-SECURITY-II-B1_Web Technologies
}
.modal-footer {
text-align: right;
}
.footer {
margin-top: 20px;
font-size: 14px;
color: #555;
}
</style>
<script>
document.addEventListener('DOMContentLoaded',
function() {
document.getElementById('userForm').addEventListener('
submit', function(event) {
event.preventDefault(); // Prevent the form
from submitting the default way
let email =
document.getElementById('email').value;
let name =
document.getElementById('name').value;
let phone =
document.getElementById('phone').value;
let emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+
$/;
7
Batch: MCA-SPZ-CYBER-SECURITY-II-B1_Web Technologies
if (!emailPattern.test(email)) {
alert('Please enter a valid email address.');
} else if (!phonePattern.test(phone)) {
alert('Please enter a valid 10-digit phone
number.');
} else {
// Display the user's details in the modal
document.getElementById('modalName').innerText =
name;
document.getElementById('modalEmail').innerText =
email;
document.getElementById('modalPhone').innerText =
phone;
document.getElementById('myModal').style.display =
'block';
}
});
8
Batch: MCA-SPZ-CYBER-SECURITY-II-B1_Web Technologies
document.getElementsByClassName('close')
[0].onclick = function() {
document.getElementById('myModal').style.display =
'none';
}
document.getElementById('closeBtn').onclick =
function() {
document.getElementById('myModal').style.display =
'none';
}
document.getElementById('myModal').style.display =
'none';
document.getElementById('userForm').submit();
}
9
Batch: MCA-SPZ-CYBER-SECURITY-II-B1_Web Technologies
document.getElementById('myModal').style.display =
'none';
}
}
});
</script>
</head>
<body>
<h1>Tech Burner</h1>
<div class="form-container">
<form id="userForm">
<h2>User Details</h2>
<label for="name">Name:</label>
<input type="text" id="name" name="name"
required>
<label for="email">Email:</label>
<input type="email" id="email" name="email"
required>
<label for="phone">Phone Number:</label>
<input type="tel" id="phone" name="phone"
required>
<button type="submit">Submit</button>
</form>
</div>
10
Batch: MCA-SPZ-CYBER-SECURITY-II-B1_Web Technologies
<div class="footer">
Contact: akshaytygaiji8@gmail.com
</div>
</body>
</html>
11
Batch: MCA-SPZ-CYBER-SECURITY-II-B1_Web Technologies
Output:
12
Batch: MCA-SPZ-CYBER-SECURITY-II-B1_Web Technologies
13
Batch: MCA-SPZ-CYBER-SECURITY-II-B1_Web Technologies
Result:
14
Batch: MCA-SPZ-CYBER-SECURITY-II-B1_Web Technologies
15