Practice Pattern
Practice Pattern
L45+L46
01. Design the HTML form for feeding the details of newly joined employee. Details include
Employee ID, Employee Name, Date of Birth, Email, Mobile Number and Permanent
Address. Maintain the non-editable Age field that would display the age in years. To enable
successful submission of form ensure
a. Email ID is of more than 14 in length. Number of characters between @ and ‘.’(dot)
should not be more than 5 and number of characters after ‘. (dot) is not more than 3.
(Use Regular Expression Validation)
b. Mobile Number field should accept only numbers and it should not be less than 10
c. Address field length should be limited to 25 characters.
d. Name field should not include any special characters. (White space allowed)
e. Employee ID should be a combination of both alphabets and numeric values.
f. DoB should not be less than 1975.
<!DOCTYPE html>
<html>
<head>
<title>Employee Registration</title>
<script>
function calculateAge() {
var dobInput = document.getElementById("dob");
var ageInput = document.getElementById("age");
var today = new Date();
var birthDate = new Date(dobInput.value);
ageInput.value = age;
}
24MCA0131
</script>
</head>
<body>
<h2>Employee Registration</h2>
<form>
<label for="employeeId">Employee ID:</label>
<input type="text" id="employeeId" name="employeeId" pattern="[A-Za-
z0-9]*[A-Za-z]+[0-9]+[A-Za-z0-9]*" title="Employee ID must contain both
alphabets and numbers" required><br><br>
<label for="age">Age:</label>
<input type="text" id="age" name="age" readonly><br><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email" pattern="[a-z0-9._%+-
]+@[a-z0-9.-]+\.[a-z]{2,3}$"
title="Email must be in valid format" required><br><br>
</body>
</html>
24MCA0131
02. Assume the vehicle service station offers service for all vehicles of Maruthi and Hyundai.
Design the HTML form to capture the details of the vehicle owned by the owner. Details may
include Vehicle Number, Vehicle Name , Color, Maker’s Name, Model Name, Model
Year, Date of Pick up, Tentative Date of Delivery, Approximate Estimate.
a. Use Radio Button for Maker’s Name.
b. Ensure the vehicle’s model entered by the user is of the respective Maker’s. (Say the
user have selected Maruthi as per Radio Button, then entering ‘Vento’ as Model’s
name is not valid)
c. Model Year should not be less than 2000
d. Date of Pickup should be always the today’s date. It is not editable.
e. Date of Delivery should not be lesser than Date of Pickup
f. Estimate amount field should capture only amount
g. Vehicle Number is of the Format : TN(space)23(space)CC(space)1000.
i. Always start with an Upper case Alphabets of length 2
ii. Followed by space
iii. Followed by 2 digit exactly
iv. Followed by space
v. Followed by 4 digit number
(Use Regular Expression Validation)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
24MCA0131
if (!validModels[maker].includes(modelName)) {
alert("Invalid model name for the selected maker.");
return false;
}
return true;
}
function validateForm(event) {
const datePickup = document.getElementById('datePickup').value;
const dateDelivery =
document.getElementById('dateDelivery').value;
<label for="color">Color:</label>
<input type="text" id="color" name="color" required>
<label>Maker's Name:</label>
<input type="radio" id="maruthi" name="maker" value="maruthi"
required>
<label for="maruthi">Maruthi</label>
<input type="radio" id="hyundai" name="maker" value="hyundai">
<label for="hyundai">Hyundai</label>
required>
<script>
document.getElementById('datePickup').value = new
Date().toLocaleDateString();
</script>
</body>
</html>
24MCA0131