Académique Documents
Professionnel Documents
Culture Documents
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Corona Patient Details Form</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
margin: 0;
padding: 0;
}
.container {
max-width: 600px;
margin: 50px auto;
background-color: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 5px;
}
input[type="text"],
select {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 5px;
box-sizing: border-box;
}
input[type="submit"] {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
}
input[type="submit"]:hover {
background-color: #45a049;
}
.error {
color: red;
}
</style>
</head>
<body>
<div class="container">
<h1>Corona Patient Details Form</h1>
<form id="coronaForm">
<label for="patientName">Patient Name:</label>
<input type="text" id="patientName" name="patientName" required>
<label for="email">Email:</label>
<input type="text" id="email" name="email" required>
<script>
const form = document.getElementById('coronaForm');
const validationMessage =
document.getElementById('validationMessage');
const output = document.getElementById('output');
form.addEventListener('submit', function(event) {
event.preventDefault();
// Validation
const emailRegex = /^[^\s@]+@[^\s@]+\.(com|gov|in)$/;
const phoneNumberRegex = /^\d{3}-\d{3}-\d{4}$/;
let isValid = true;
if (!emailRegex.test(email)) {
displayError('Email must end with .com, .gov, or .in');
isValid = false;
}
if (!phoneNumberRegex.test(phoneNumber)) {
displayError('Invalid Phone Number. Format should be XXX-XXX-
XXXX');
isValid = false;
}
if (isValid) {
validationMessage.textContent = '';
const selectedItems = Array.from(requiredItems).map(option =>
option.value).join(', ');
output.innerHTML = `
<p>Patient Name: ${patientName}</p>
<p>Email: ${email}</p>
<p>Phone Number: ${phoneNumber}</p>
<p>Required Items: ${selectedItems}</p>
<p>Patient Message: ${patientMessage}</p>
<p>Information about CORONA: $
{checkForCoronaKeywords(patientMessage)}</p>
<p>Submission Time: ${new Date().toLocaleString()}</p>
`;
}
});
function displayError(message) {
validationMessage.textContent = message;
}
function checkForCoronaKeywords(message) {
const keywords = ['COVID19', 'COVID', 'corona', 'coronavirus'];
const regex = new RegExp(keywords.join('|'), 'gi');
const matches = message.match(regex);
return matches ? 'Information about CORONA' : 'No information
about CORONA found';
}
</script>
</body>
</html>
2.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
body {
background-color: #f2f2f2;
margin: 0;
padding: 0;
.container {
max-width: 600px;
background-color: #fff;
padding: 20px;
border-radius: 10px;
h1 {
text-align: center;
margin-bottom: 20px;
label {
display: block;
margin-bottom: 5px;
input[type="text"],
select {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border-radius: 5px;
box-sizing: border-box;
input[type="submit"] {
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
input[type="submit"]:hover {
background-color: #45a049;
.error {
color: red;
}
</style>
</head>
<body>
<div class="container">
<form id="registrationForm">
<label for="city">City:</label>
<label for="email">Email:</label>
<label for="state">State:</label>
<option value="Karnataka">Karnataka</option>
<option value="Kerala">Kerala</option>
</select>
</select>
<option value="Regular">Regular</option>
<option value="VIP">VIP</option>
</select>
<option value="Vegetarian">Vegetarian</option>
<option value="Non-Vegetarian">Non-Vegetarian</option>
</select>
</form>
<div id="output"></div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script>
$(function() {
$("#city").autocomplete({
source: cities
});
});
$('#registrationForm').submit(function(event) {
event.preventDefault();
// Validation
if (!regNoRegex.test(firstName)) {
displayError('First name should be VIT student reg.no of 20, 21, 22, and 23 batch students
of MTech SE.');
return;
return;
if (!zipCodeRegex.test(zipCode)) {
displayError('Zip code should be exactly six digits with state code followed by one space or
hyphen, then postal code with 4 digits. Example: 63-2043 or 63 2043');
return;
}
if (!emailRegex.test(email)) {
return;
validationMessage.textContent = '';
output.innerHTML = `
<p>City: ${city}</p>
<p>Email: ${email}</p>
<p>State: ${state}</p>
`;
});
function displayError(message) {
$('#validationMessage').text(message);
</script>
</body>
</html>