Certainly! Below is a complete example of an advance request form created using HTML, CSS, and JavaScript. The form features a professional UI with advanced animations to enhance the user experience.
HTML (index.html):
html Copy code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Advance Request Form</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<form id="advance-request-form">
<h1>Advance Request Form</h1>
<div class="input-group">
<input type="text" id="name" required>
<label for="name">Full Name</label>
<span class="bar"></span>
</div>
<div class="input-group">
<input type="text" id="employee-id" required>
<label for="employee-id">Employee ID</label>
<span class="bar"></span>
</div>
<div class="input-group">
<input type="text" id="department" required>
<label for="department">Department</label>
<span class="bar"></span>
</div>
<div class="input-group">
<input type="number" id="amount" required>
<label for="amount">Amount Requested</label>
<span class="bar"></span>
</div>
<div class="input-group">
<input type="date" id="date-needed" required>
<label for="date-needed">Date Needed</label>
<span class="bar"></span>
</div>
<div class="input-group textarea">
<textarea id="purpose" required></textarea>
<label for="purpose">Purpose of Request</label>
<span class="bar"></span>
</div>
<button type="submit">Submit Request</button>
</form>
</div>
<script src="script.js"></script>
</body>
</html>
CSS (styles.css):
css Copy code
/* Reset CSS */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(45deg, #1de099, #1dc8cd);
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.container {
background: #fff;
padding: 40px;
border-radius: 10px;
box-shadow: 0 10px 25px rgba(0,0,0,0.1);
animation: fadeIn 1s ease-in-out;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(-20px); }
to { opacity: 1; transform: translateY(0); }
}
#advance-request-form {
width: 400px;
}
#advance-request-form h1 {
text-align: center;
margin-bottom: 30px;
color: #333;
position: relative;
}
#advance-request-form h1::after {
content: '';
width: 50px;
height: 3px;
background: #1dc8cd;
position: absolute;
left: 50%;
transform: translateX(-50%);
bottom: -10px;
}
.input-group {
position: relative;
margin-bottom: 30px;
}
.input-group input,
.input-group textarea {
width: 100%;
border: none;
border-bottom: 2px solid #ccc;
padding: 10px 0;
font-size: 16px;
color: #333;
background: transparent;
transition: all 0.3s ease;
}
.input-group input:focus,
.input-group textarea:focus {
outline: none;
border-bottom-color: #1dc8cd;
}
.input-group label {
position: absolute;
top: 10px;
left: 0;
font-size: 16px;
color: #666;
pointer-events: none;
transition: all 0.3s ease;
}
.input-group input:focus + label,
.input-group input:not(:placeholder-shown) + label,
.input-group textarea:focus + label,
.input-group textarea:not(:placeholder-shown) + label {
top: -20px;
font-size: 14px;
color: #1dc8cd;
}
.input-group .bar {
position: absolute;
left: 0;
bottom: 0;
background: #1dc8cd;
width: 0%;
height: 2px;
transition: width 0.3s ease;
}
.input-group input:focus ~ .bar,
.input-group textarea:focus ~ .bar {
width: 100%;
}
.input-group.textarea {
margin-bottom: 40px;
}
.input-group.textarea textarea {
height: 100px;
resize: none;
}
button[type="submit"] {
width: 100%;
padding: 15px;
border: none;
background: #1dc8cd;
color: #fff;
font-size: 16px;
border-radius: 50px;
cursor: pointer;
transition: background 0.3s ease;
position: relative;
overflow: hidden;
}
button[type="submit"]::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
transition: left 0.5s;
}
button[type="submit"]:hover {
background: #1de099;
}
button[type="submit"]:hover::before {
left: 100%;
}
button[type="submit"]:active {
transform: scale(0.98);
}
/* Responsive Design */
@media (max-width: 480px) {
#advance-request-form {
width: 100%;
}
}
JavaScript (script.js):
javascript Copy code
document.getElementById('advance-request-form').addEventListener('submit', function(event) {
event.preventDefault();
// Simulate form submission animation
this.classList.add('form-submitted');
setTimeout(() => {
alert('Your advance request has been submitted successfully!');
this.reset();
this.classList.remove('form-submitted');
}, 2000);
});
Explanation:
HTML:
The form contains various input fields like Full Name, Employee ID, Department, Amount Requested, Date Needed, and Purpose of Request.
The span elements with class bar are used for the underline animation effect.
CSS:
The form container uses a subtle fade-in animation when the page loads.
Input fields have floating labels that animate upwards when the user focuses or inputs text.
The underline (.bar) under the input fields animates from left to right on focus.
The submit button has an animated hover effect with a sliding light overlay.
The background uses a gradient for a modern look.
Media queries ensure the form is responsive on smaller screens.
JavaScript:
Prevents the default form submission to allow for a custom submission animation.
Adds a class form-submitted to the form to trigger any additional animations or styles (you can extend this as needed).
Simulates a form submission with a timeout and displays an alert message.
After submission, it resets the form and removes the submission class.
How to Use:
Create the Files:
Create three files in the same directory: index.html, styles.css, and script.js.
Copy the respective code into each file.
Run the Application:
Open index.html in a web browser.
Ensure that the CSS and JavaScript files are correctly linked.
Customize as Needed:
You can modify the color scheme by changing the gradient in the body selector and the colors used throughout the CSS.
Extend the JavaScript to handle real form submissions, validations, or integrate with a backend service.
Preview:
[image: Advance Request Form Preview] open
(Note: Since I cannot display images, please imagine a modern, professional form with subtle animations as described.)
Additional Enhancements:
Input Validation:
You can add real-time validation to the form fields and display error messages.
Loader Animation:
Replace the alert with a custom modal that has a loader animation to indicate processing.
Advanced Animations:
Utilize CSS animations like @keyframes for more complex animations.
Use libraries like GSAP or Anime.js for advanced JavaScript animations (ensure to include their scripts).
Accessibility Considerations:
Focus States:
Ensure that focus states for inputs and buttons are visible for keyboard navigation.
Labels:
All inputs have associated <label> elements for better accessibility.
Contrast Ratios:
Use colors that have sufficient contrast between text and background for readability.
Feel free to customize the form further to suit your specific needs. If you have any questions or need assistance with additional features, please let me know!